CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

比较引用对象 (ActiveX)

2023-1-4 17:37| 发布者: admin| 查看: 515| 评论: 0|来自: AutoCAD

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

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

支持的平台:仅窗口

班级信息

类名

AcadComparedReference

对象继承
Object
   AcadObject
      AcadEntity
         AcadBlockReference
            AcadExternalReference
               AcadComparedReference
创建使用

VBA

Not applicable
访问方式

VBA

ModelSpace.Item

Remarks

The object inherits its members from the object. You can use ActiveX to query and edit entities in an AutoCAD drawing. However, you cannot create a object with ActiveX. ComparedReferenceExternalReferenceComparedReferenceComparedReference

There is no member property that allows you to identify an object as being of the type; however, you can cast-type an or to the object type and use error handling to determine if the cast was successful. ExternalReferenceComparedReferenceAcadEntityAcadExternalReferenceAcadComparedReference

The following code samples show how you can use cast-typing to determine if an entity is of type . 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

Visual 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 )

GMT+8, 2024-5-12 14:10

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部