CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

SetCustomScale Method (ActiveX)

2023-1-4 02:28| 发布者: admin| 查看: 398| 评论: 0|来自: AutoCAD

摘要: 设置布局或打印配置的自定义比例。

设置布局或打印配置的自定义比例。

支持的平台:仅窗口

签名

工 务 局:

object.SetCustomScale Numerator, Denominator
对象

类型:布局绘图配置

此方法适用的对象。

分子

访问:仅输入

类型:

一个正数,表示比例比中的分子。此值表示刻度的英寸数或毫米数。

分母

访问:仅输入

类型:

一个正数,表示刻度比中的分母。此值表示比例的绘图单位数。

返回值(RetVal)

无返回值。

言论

分子参数的单位可以在属性中找到。PaperUnits

分子和分参数必须大于零。

在再生图形之前,此方法所做的更改将不可见。使用该方法再生图形。Regen

例子

工 务 局:

Sub Example_SetCustomScale()
    ' This example will access the Layouts collection for the current drawing
    ' and list basic information about the custom scale for each Layout.
    ' It will then change the custom scale information for model space and re-display
    ' the scale information.

    Dim Layouts As AcadLayouts, Layout As ACADLayout
    Dim msg As String
    Dim Numerator As Double, Denominator As Double
    Dim Measurement As String
    
    ' Display current scale information
    GoSub DISPLAY_SCALE_INFO
    
    ' Modify scale
    Numerator = 1
    Denominator = 1
    
    ThisDrawing.Layouts("Model").SetCustomScale Numerator, Denominator
    ThisDrawing.Regen acAllViewports
            
    ' Display new scale information
    GoSub DISPLAY_SCALE_INFO
        
    Exit Sub
    
DISPLAY_SCALE_INFO:
    ' Get layouts collection from document object
    Set Layouts = ThisDrawing.Layouts
    
    msg = vbCrLf & vbCrLf   ' Start with a space
    
    ' Get the scale information of every layout in this drawing
    For Each Layout In Layouts
        msg = msg & Layout.name & vbCrLf
        
        ' Get scale information
        Layout.GetCustomScale Numerator, Denominator
        
        ' Identify whether inches or millimeters are being used.
        Measurement = IIf(Layout.PaperUnits = acInches, " inch(es)", " millimeter(s)")
        
        ' Format for display
        msg = msg & vbTab & "Contains " & Numerator & Measurement & vbCrLf
        msg = msg & vbTab & "Contains " & Denominator & " drawing units" & vbCrLf
        msg = msg & "_____________________" & vbCrLf
        
    Next
    
    ' Display custom scale information
    MsgBox "Custom scale information for the current drawing is: " & msg
    
    Return
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_SetCustomScale()
    ;; This example will access the Layouts collection for the current drawing
    ;; and list basic information about the custom scale for each Layout.
    ;; It will then change the custom scale information for model space and re-display
    ;; the scale information.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Display current scale information
    (setq Layouts (vla-get-Layouts doc))
    
    (setq msg "")
    
    ;; Get the scale information of every layout in this drawing
    (vlax-for Layout Layouts
        (setq msg (strcat msg (vla-get-Name Layout) "\n"))
        
        ;; Get scale information
        (vla-GetCustomScale Layout 'Numerator 'Denominator)
        
        ;; Are we using inches or millimeters
        (setq Measurement (if (= (vla-get-PaperUnits Layout) acInches) " inch(es)\n" " millimeter(s)\n"))
        
        ;; Format for display
        (setq msg (strcat msg "  Contains " (rtos Numerator 2) Measurement
                              "  Contains " (rtos Denominator 2) " drawing units\n"
                              "_____________________\n"))   
    )
    
    ;; Display custom scale information
    (alert (strcat "Custom scale information for the current drawing is: " msg))
  
    ;; Modify scale
    (setq Numerator 1
          Denominator 1)
    
    (vla-SetCustomScale (vla-Item (vla-get-Layouts doc) "Model") Numerator Denominator)
    (vla-Regen doc acAllViewports)
            
    ;; Display new scale information
    (setq Layouts (vla-get-Layouts doc))
    
    (setq msg "")
    
    ;; Get the scale information of every layout in this drawing
    (vlax-for Layout Layouts
        (setq msg (strcat msg (vla-get-Name Layout) "\n"))
        
        ;; Get scale information
        (vla-GetCustomScale Layout 'Numerator 'Denominator)
        
        ;; Are we using inches or millimeters
        (setq Measurement (if (= (vla-get-PaperUnits Layout) acInches) " inch(es)\n" " millimeter(s)\n"))
        
        ;; Format for display
        (setq msg (strcat msg "  Contains " (rtos Numerator 2) Measurement
                              "  Contains " (rtos Denominator 2) " drawing units\n"
                              "_____________________\n"))   
    )

    ;; Display custom scale information
    (alert (strcat "Custom scale information for the current drawing is: " msg))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-11 18:29

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部