获取布局或打印配置的边距。 支持的平台:仅窗口 签名工 务 局: object.GetPaperMargins LowerLeft, UpperRight 返回值(RetVal)无返回值。 言论打印原点从纸张边缘偏移此处指定的边距。 这些值的单位由属性指定。PaperUnits 例子工 务 局: Sub Example_GetPaperMargins()
' This example will access the Layouts collection for the current drawing
' and list the plot size based on the margins returned from the GetPaperMargins
' property for each Layout except model space.
Dim Layouts As AcadLayouts, Layout As ACADLayout
Dim msg As String
Dim Measurement As String
Dim MarginLowerLeft As Variant, MarginUpperRight As Variant
Dim PaperHeight As Double, PaperWidth As Double
Dim PlotHeight As Double, PlotWidth As Double
' Get layouts collection from document object
Set Layouts = ThisDrawing.Layouts
msg = vbCrLf & vbCrLf ' Start with a space
' Get the margin information of every layout in this drawing
For Each Layout In Layouts
' Skip model space
If Layout.name = "Model" Then GoTo NEXT_LAYOUT
ThisDrawing.ActiveLayout = Layout
msg = msg & Layout.name & vbCrLf
' Get paper size and margin information
Layout.GetPaperMargins MarginLowerLeft, MarginUpperRight
Layout.GetPaperSize PaperWidth, PaperHeight
' Do plot area calculations
PlotWidth = PaperWidth - (MarginUpperRight(0) - MarginLowerLeft(0))
PlotHeight = PaperHeight - (MarginUpperRight(1) - MarginLowerLeft(1))
' Are we using inches or millimeters
Measurement = " millimeter(s)"
' Format for display
msg = msg & vbTab & "The paper size for this layout is: " & PaperWidth & " X " & PaperHeight & Measurement & vbCrLf & vbCrLf
msg = msg & vbTab & "The paper margins are: " & vbCrLf & _
vbTab & vbTab & "Left" & vbTab & "(" & MarginLowerLeft(0) & ")" & Measurement & vbCrLf & _
vbTab & vbTab & "Right" & vbTab & "(" & MarginUpperRight(0) & ")" & Measurement & vbCrLf & _
vbTab & vbTab & "Top" & vbTab & "(" & MarginUpperRight(1) & ")" & Measurement & vbCrLf & _
vbTab & vbTab & "Bottom" & vbTab & "(" & MarginLowerLeft(1) & ")" & Measurement & vbCrLf & vbCrLf
msg = msg & vbTab & "The paper plot area for this layout is: " & PlotWidth & " X " & PlotHeight & Measurement & vbCrLf
msg = msg & "_____________________" & vbCrLf
NEXT_LAYOUT:
Next
' Display paper size and margin information
MsgBox "Paper plot information for the current drawing is: " & msg
End Sub
Visual LISP: (vl-load-com)
(defun c:Example_GetPaperMargins()
;; This example will access the Layouts collection for the current drawing
;; and list the plot size based on the margins returned from the GetPaperMargins
;; property for each Layout except model space.
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
;; Get layouts collection from document object
(setq Layouts (vla-get-Layouts doc))
(setq msg "") ;; Start with a space
;; Get the margin information of every layout in this drawing
(vlax-for Layout Layouts
;; Skip model space
(if (/= (vla-get-Name Layout) "Model")
(progn
(vla-put-ActiveLayout doc Layout)
(setq msg (strcat msg (vla-get-Name Layout) "\n"))
;; Get paper size and margin information
(vla-GetPaperMargins Layout 'MarginLowerLeft 'MarginUpperRight)
(vla-GetPaperSize Layout 'PaperWidth 'PaperHeight)
;; Do plot area calculations
(setq PlotWidth (- PaperWidth (- (vlax-safearray-get-element MarginUpperRight 0) (vlax-safearray-get-element MarginLowerLeft 0))))
(setq PlotHeight (- PaperHeight (- (vlax-safearray-get-element MarginUpperRight 1) (vlax-safearray-get-element MarginLowerLeft 1))))
;; Are we using inches or millimeters
(setq Measurement " millimeter(s)")
;; Format for display
(setq msg (strcat msg "The paper size for this layout is: " (rtos PaperWidth 2) " X " (rtos PaperHeight 2) Measurement "\n\n"))
(setq msg (strcat msg " The paper margins are: \n"
" Left (" (rtos (vlax-safearray-get-element MarginLowerLeft 0) 2) ")" Measurement "\n"
" Right (" (rtos (vlax-safearray-get-element MarginUpperRight 0) 2) ")" Measurement "\n"
" Top (" (rtos (vlax-safearray-get-element MarginUpperRight 1) 2) ")" Measurement "\n"
" Bottom (" (rtos (vlax-safearray-get-element MarginLowerLeft 1) 2) ")" Measurement "\n\n"))
(setq msg (strcat msg "The paper plot area for this layout is: " (rtos PlotWidth 2) " X " (rtos PlotHeight 2) Measurement "\n"))
(setq msg (strcat msg "_____________________\n"))
)
)
)
;; Display paper size and margin information
(alert (strcat "Paper plot information for the current drawing is: " msg))
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 08:43
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.