レイアウトまたは印刷設定の余白を取得します。
サポートされているプラットフォーム: Windows のみ
VBA:
object.GetPaperMargins LowerLeft, UpperRight
タイプ: Layout、PlotConfiguration
このメソッドが適用されるオブジェクト。
アクセス: 出力のみ
タイプ: バリアント型(2 要素の倍精度浮動小数点数型配列)
左下余白の X および Y の値。
アクセス: 出力のみ
タイプ: バリアント型(2 要素の倍精度浮動小数点数型配列)
右上余白の X および Y の値。
戻り値はありません。
印刷基点は、ここで指定したマージンだけ用紙の端からオフセットされます。
値の単位は PaperUnits プロパティで指定します。
VBA:
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))
)