CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2024 开发者帮助

HasVpAssociation 属性 (ActiveX)

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

HasVpAssociation 属性 (ActiveX)

指定视图是否与纸张空间视口相关联。

支持的平台:仅限 Windows

签名

VBA:

object.HasVpAssociation
对象

类型: 查看

此属性应用于的对象。

属性值

只读:

类型:布尔

  • True:视图与图纸空间视口相关联。
  • False:视图未与图纸空间视口关联。

言论

没有其他评论。

例子

VBA:

Sub Example_HasVpAssociation()
    ' This example demonstrates the
    ' CategoryName, LayoutId, LayerState,
    ' and HasVpAssociation properties of the View object
    
    Dim oLSM As AcadLayerStateManager

    ' Access the LayerStateManager object
    Set oLSM = ThisDrawing.Application. _
       GetInterfaceObject("AutoCAD.AcadLayerStateManager." & Left(AcadApplication.Version, 2))

    ' Associate the current drawing database with LayerStateManager
    oLSM.SetDatabase ThisDrawing.Database

    oLSM.Save "My Layer State", acLsColor + acLsLineType
    
    ' Create a view named "New_View" in current drawing
    Dim viewObj As AcadView
   
    ' Add the view to the views collection
    Set viewObj = ThisDrawing.Views.Add("New_View")
    MsgBox viewObj.Name & " has been added." & vbCrLf & _
           "Height: " & viewObj.Height & vbCrLf & _
           "Width: " & viewObj.Width, , "Example"
    
    viewObj.CategoryName = "My View Category"
    viewObj.LayerState = "My Layer State"
    
    viewObj.LayoutId = ThisDrawing.Layouts(1).ObjectID
        
    MsgBox viewObj.CategoryName & " is the Category name." & vbCrLf & _
            viewObj.LayoutId & " is the Layout ID." & vbCrLf & _
            viewObj.LayerState & " is the Layer state."
   
    If viewObj.HasVpAssociation = True Then
        MsgBox "The view is associated with a paper space viewport."
    Else
        MsgBox "The view is not associated with a paper space viewport."
   End If
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_HasVpAssociation()
    ;; This example demonstrates the
    ;; CategoryName, LayoutId, LayerState,
    ;; and HasVpAssociation properties of the View object
    (setq acadObj (vlax-get-acad-object)
          doc (vla-get-ActiveDocument acadObj))

    ;; Add the view to the views collection
    (setq viewObj (vla-Add (vla-get-Views doc) "New_View"))
    (alert (strcat (vla-get-Name viewObj) " has been added."
                   "\nHeight: " (rtos (vla-get-Height viewObj) 2)
                   "\nWidth: " (rtos (vla-get-Width viewObj) 2)
           )
    )
    
    (vla-put-CategoryName viewObj "My View Category")
    (vla-put-LayoutId viewObj (vla-get-ObjectID (vla-Item (vla-get-Layouts doc) 1)))

    ;; If using AutoCAD, we can utilize the Layer State Manager
    (if (/= (strcase (getvar "PROGRAM") T) "acadlt")
        (progn
            ;; Access the LayerStateManager object
            (setq oLSM (vla-GetInterfaceObject acadObj (strcat "AutoCAD.AcadLayerStateManager." (substr (getvar "ACADVER") 1 2))))

            ;; Associate the current drawing database with LayerStateManager
            (vla-SetDatabase oLSM (vla-get-Database doc))

            (vla-Save oLSM "My Layer State" (+ acLsColor acLsLineType))
            (vla-put-LayerState viewObj "My Layer State")
      
            (vlax-release-object oLSM)
        )
    )

    (alert (strcat (vla-get-CategoryName viewObj) " is the Category name."
                   "\n" (itoa (vla-get-LayoutId viewObj)) " is the Layout ID."
                   "\n" (vla-get-LayerState viewObj) " is the Layer state."
           )
    )
   
    (if (= (vla-get-HasVpAssociation viewObj) :vlax-true)
        (alert "The view is associated with a paper space viewport.")
        (alert "The view is not associated with a paper space viewport.")
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-1-19 06:40

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部