Key32 Property (ActiveX)

The object ID of the source object in the CopyObjects operation for a 64-bit system. (Obsolete)

Supported platforms: Windows only

Signature

VBA:

object.Key32
object

Type: IDPair

The object this property applies to.

Property Value

Read-only: Yes

Type: Long

The object ID of the source object.

Remarks

Use the Value32 property to get the object ID of the newly created cloned object.

Examples

VBA:

Sub Example_Key()
    ' This example creates two Circle objects and uses the CopyObjects
    ' method to copy them. It then returns the
    ' object IDs of the source objects using the Key property and uses these
    ' values to remove the original (source) objects

    Dim circleObj1 As AcadCircle, circleObj2 As AcadCircle
    Dim circleObj1Copy As AcadCircle, circleObj2Copy As AcadCircle
    Dim centerPoint(0 To 2) As Double
    Dim radius1 As Double, radius2 As Double
    Dim radius1Copy As Double, radius2Copy As Double
    Dim objCollection(0 To 1) As Object
    Dim retObjects As Variant
    Dim IDPairs As Variant
    Dim SourceObject As AcadObject
    
    ' Define the Circle object
    centerPoint(0) = 0: centerPoint(1) = 0: centerPoint(2) = 0
    radius1 = 5#: radius2 = 7#
    radius1Copy = 1#: radius2Copy = 2#
    
    ' Add two circles to the drawing
    Set circleObj1 = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius1)
    Set circleObj2 = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius2)
    ThisDrawing.Application.ZoomAll
    
    ' Copy objects
    '
    ' First put the objects to be copied into a form compatible with CopyObjects
    Set objCollection(0) = circleObj1
    Set objCollection(1) = circleObj2
    
    ' Copy object and get back a collection of the new objects (copies)
    retObjects = ThisDrawing.CopyObjects(objCollection, , IDPairs)
    
    ' Get newly created object and apply new properties to the copies
    Set circleObj1Copy = retObjects(0)
    Set circleObj2Copy = retObjects(1)
    
    circleObj1Copy.radius = radius1Copy
    circleObj2Copy.radius = radius2Copy
        
    ThisDrawing.Application.ZoomAll
    ThisDrawing.Regen acAllViewports
    
    ' Display the object IDs of the source objects used for the copy
    MsgBox "The first source object ID is: " & IDPairs(0).key & vbCrLf & _
           "The second source object ID is: " & IDPairs(1).key

    ' This key can be used with objectIDtoObject to reference the source objects,
    ' which is handy if the user manually selected the source objects.
    '
    ' Delete the source objects from the ID obtained
    Set SourceObject = ThisDrawing.ObjectIdToObject(IDPairs(0).key)
    SourceObject.Delete
    Set SourceObject = ThisDrawing.ObjectIdToObject(IDPairs(1).key)
    SourceObject.Delete
    
    ThisDrawing.Regen acAllViewports
    
    MsgBox "The source objects have just been deleted!", vbInformation
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Key()
    ;; This example creates two Circle objects and uses the CopyObjects
    ;; method to copy them. It then returns the
    ;; object IDs of the source objects using the Key property and uses these
    ;; values to remove the original (source) objects
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the Circle object
    (setq centerPoint (vlax-3d-point 0 0 0) 
          radius1 5
          radius2 7
          radius1Copy 1
          radius2Copy 2)
    
    ;; Add two circles to the drawing
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq circleObj1 (vla-AddCircle modelSpace centerPoint radius1))
    (setq circleObj2 (vla-AddCircle modelSpace centerPoint radius2))
    (vla-ZoomAll acadObj)
    
    ;; Copy objects
    ;;
    ;; First put the objects to be copied into a form compatible with CopyObjects
    (setq objCollection (vlax-make-safearray vlax-vbObject '(0 . 1)))
    (vlax-safearray-put-element objCollection 0 circleObj1)
    (vlax-safearray-put-element objCollection 1 circleObj2)
    
    ;; Copy object and get back a collection of the new objects (copies)
    (setq retObjects (vlax-variant-value (vla-CopyObjects doc objCollection nil 'IDPairs)))
    
    ;; Get newly created object and apply new properties to the copies
    (setq circleObj1Copy (vlax-safearray-get-element retObjects 0))
    (setq circleObj2Copy (vlax-safearray-get-element retObjects 1))
    
    (vla-put-Radius circleObj1Copy radius1Copy)
    (vla-put-Radius circleObj2Copy radius2Copy)
        
    (vla-ZoomAll acadObj)
    (vla-Regen doc acAllViewports)
    
    ;; Display the object IDs of the source objects used for the copy
    (alert (strcat "The first source object ID is: " (itoa (vla-get-Key (vlax-safearray-get-element IDPairs 0)))
                   "\nThe second source object ID is: " (itoa (vla-get-Key (vlax-safearray-get-element IDPairs 1)))))

    ;; This key can be used with objectIDtoObject to reference the source objects,
    ;; which is handy if the user manually selected the source objects.
    ;;
    ;; Delete the source objects from the ID obtained
    (setq SourceObject (vla-ObjectIdToObject doc (vla-get-Key (vlax-safearray-get-element IDPairs 0))))
    (vla-Delete SourceObject)
    (setq SourceObject (vla-ObjectIdToObject doc (vla-get-Key (vlax-safearray-get-element IDPairs 1))))
    (vla-Delete SourceObject)
    
    (vla-Regen doc acAllViewports)
    
    (alert "The source objects have just been deleted!")
)