ComparedReference Object (ActiveX)

External reference that represents the drawing being compared to the current drawing.

Supported Platforms: Windows only

Class Information

Class Name

AcadComparedReference

Object Inheritance
Object
   AcadObject
      AcadEntity
         AcadBlockReference
            AcadExternalReference
               AcadComparedReference
Create Using

VBA

Not applicable
Access Via

VBA

ModelSpace.Item

Members

These members are part of this object:

Remarks

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

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

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