CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

GetPaperMargins Method (ActiveX)

2023-1-4 07:18| 发布者: admin| 查看: 746| 评论: 0|来自: AutoCAD

摘要: 获取布局或打印配置的边距。

获取布局或打印配置的边距。

支持的平台:仅窗口

签名

工 务 局:

object.GetPaperMargins LowerLeft, UpperRight
对象

类型:布局绘图配置

此方法适用的对象。

左下角

访问:仅输出

类型:变体(双精度的双元素数组)

左下边距的XY值。

右上

访问:仅输出

类型:变体(双精度的双元素数组)

右上边距的XY值。

返回值(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))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-12 02:27

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部