CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2023 开发者帮助

CustomScale 属性 (ActiveX)

2024-5-18 18:56| 发布者: admin| 查看: 88| 评论: 0|原作者: admin|来自: AutoCAD

CustomScale 属性 (ActiveX)

指定视口的自定义比例因子。

支持的平台:仅限 Windows

签名

VBA:

object.CustomScale
对象

类型: PViewport

此属性应用于的对象。

属性值

只读:

类型:

视口的自定义比例因子。

言论

若要将视口设置为自定义比例,请先将属性设置为 ,然后使用此属性定义自定义比例值。StandardScaleacVpCustomScale

例子

VBA:

Sub Example_CustomScale()
    ' This example adds a line in paper space, creates a new paper space viewport, and cycles through some common paper space custom scale sizes
    ' for the new paper space viewport
   
    Dim lineObj As AcadLine
    Dim PViewPort As AcadPViewport
    Dim startPoint(0 To 2) As Double, endPoint(0 To 2)  As Double
    Dim center(0 To 2) As Double
    Dim width As Double, height As Double
    
    ' Define the start and end points for the line
    startPoint(0) = 1: startPoint(1) = 1: startPoint(2) = 0
    endPoint(0) = 5: endPoint(1) = 5: endPoint(2) = 0
    
    ' Define the paper space viewport
    center(0) = 3: center(1) = 3: center(2) = 0
    width = 40: height = 40
    
    ' Create the line in paper space
    Set lineObj = ThisDrawing.PaperSpace.AddLine(startPoint, endPoint)
       
    ' Create the paper space viewport
    Set PViewPort = ThisDrawing.PaperSpace.AddPViewport(center, width, height)
   
    ' Set the paper space viewport scale to custom 
    PViewPort.StandardScale = acVpCustomScale
    
    ' Change from model space to paper space
    ThisDrawing.ActiveSpace = acPaperSpace
    
    ' Read and display the existing paper space viewport scale setting
    MsgBox "The scale of the new PViewport is: " & PViewPort.CustomScale
    
    ' Change the custom scale setting to 1:10 scale
    PViewPort.CustomScale = 0.1
   
    ' Read and display the new paper space viewport scale setting
    MsgBox "The scale of the new PViewport has been changed to: " & PViewPort.CustomScale

End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_CustomScale()
    ;; This example adds a line in paper space, creates a new paper space viewport, and cycles through some common paper space custom scale sizes
    ;; for the new paper space viewport
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Define the start and end points for the line
    (setq startPoint (vlax-3d-point 1 1 0)
          endPoint (vlax-3d-point 5 5 0)) 
    
    ;; Define the paper space viewport
    (setq center (vlax-3d-point 3 3 0)
          width 40
          height 40)
    
    ;; Create the line in paper space
    (setq paperSpace (vla-get-PaperSpace doc))
    (setq lineObj (vla-AddLine paperSpace startPoint endPoint))
       
    ;; Create the paper space viewport
    (setq PViewPort (vla-AddPViewport paperSpace center width height))
   
    ;; Set the paper space viewport scale to custom 
    (vla-put-StandardScale PViewPort acVpCustomScale)
    
    ;; Change from model space to paper space
    (vla-put-ActiveSpace doc acPaperSpace)
    (vla-Regen doc acAllViewports)
    (vla-ZoomAll acadObj)
    
    ;; Read and display the existing paper space viewport scale setting
    (alert (strcat "The scale of the new PViewport is: " (rtos (vla-get-CustomScale PViewPort) 2)))
    
    ;; Change the custom scale setting to 1:10 scale
    (vla-put-CustomScale PViewPort 0.1)
   
    ;; Read and display the new paper space viewport scale setting
    (alert (strcat "The scale of the new PViewport has been changed to: " (rtos (vla-get-CustomScale PViewPort) 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 11:45

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部