CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2024 开发者帮助

ComparedReference 对象 (ActiveX)

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

ComparedReference 对象 (ActiveX)

表示要与当前图形进行比较的图形的外部参照。

支持的平台:仅限 Windows

班级信息

类名

AcadComparedReference

对象继承
Object
   AcadObject
      AcadEntity
         AcadBlockReference
            AcadExternalReference
               AcadComparedReference
创建方式

VBA的

Not applicable
通过访问方式

VBA的

ModelSpace.Item

言论

该对象从该对象继承其成员。可以使用 ActiveX 查询和编辑 AutoCAD 图形中的图元。但是,您不能使用 ActiveX 创建对象。ComparedReferenceExternalReferenceComparedReferenceComparedReference

没有允许您将对象标识为该类型的成员属性;但是,您可以将 OR 强制转换为对象类型,并使用错误处理来确定强制转换是否成功。ExternalReferenceComparedReferenceAcadEntityAcadExternalReferenceAcadComparedReference

以下代码示例演示如何使用强制转换类型来确定实体是否为 类型。ComparedReference

VBA:

' Checks to see if an object is of the ComparedReference type
Sub CheckForComparedReference()
  Dim ent As AcadEntity
  Dim comRef As AcadComparedReference
  
  On Error Resume Next

  ' Step through all the objects in model space
  For Each ent In ThisDrawing.ModelSpace
  
    ' Check to see if the object is a Block Reference
    If ent.ObjectName = "AcDbBlockReference" Then
    
      ' Try to cast the entity (Block Reference) to a ComparedReference
      Set comRef = ent
    
      ' If an occurs, then the entity is not a ComparedReference
      If Err <> 0 Then
        MsgBox "Not a Compared Reference"
      Else
        MsgBox "Xref Name: " + comRef.Name + vbLf + "Compared Reference"
      End If
    
      ' Clear the Error object
      Err.Clear
    End If
  Next ent
End Sub

可视化 LISP:

(vl-load-com)
(defun c:CheckForComparedReference()
  ;; Checks to see if an object is of the ComparedReference type
  (setq acadObj (vlax-get-acad-object))
  (setq doc (vla-get-ActiveDocument acadObj))

  ;; Step through all the objects in model space
  (vlax-for obj (vla-get-ModelSpace doc)
    ;; Check to see if the object is a Block Reference
    (if (= (vla-get-objectname obj) "AcDbBlockReference")
      (progn
        ;; Transform the VLA-OBJECT to an ENAME
        (setq entName (vlax-vla-object->ename obj))

        ;; Check to see what the value of the IsComparedReference property is of the entity
        (if (vl-catch-all-error-p (vl-catch-all-apply 'getpropertyvalue (list entName "IsComparedReference")))
          ;; If an error occurs, then the entity is not a ComparedReference
          (alert "Not a Compared Reference")
          (alert (strcat "Xref Name: "
                         (vla-get-name obj)
                         "\nCompared Reference"))
        )
      )
    )
  )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-3-14 07:54

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部