Copy Method (ActiveX)

Duplicates the given object to the same location.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.Copy
object

Type: All drawing objects, AttributeReference, Dimension

The objects this method applies to.

Return Value (RetVal)

Type: All drawing objects, AttributeReference, Dimension

The newly created duplicate object.

Remarks

AttributeReference: You should not attempt to use this method on AttributeReference objects. AttributeReference objects inherit this method because they are one of the drawing objects, however, it is not feasible to perform this operation on an attribute reference.

Note: You cannot execute this method while simultaneously iterating through a collection. An iteration will open the work space for a read-only operation, while this method attempts to perform a read-write operation. Complete any iteration before you call this method.

Examples

VBA:

Sub Example_Copy()
    ' This example creates a circle and then copies
    ' that circle. The new circle is then moved.
    
    ' Create the circle
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 2#: center(1) = 2#: center(2) = 0#
    radius = 0.5
    Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)
    ZoomAll
    MsgBox "Copy the circle.", , "Copy Example"
    
    ' Copy the circle
    Dim copyCircleObj As AcadCircle
    Set copyCircleObj = circleObj.Copy()
    
    ' Define the points that make up the move vector
    Dim point1(0 To 2) As Double
    Dim point2(0 To 2) As Double
    point1(0) = 0: point1(1) = 0: point1(2) = 0
    point2(0) = 2: point2(1) = 0: point2(2) = 0
        
    MsgBox "Move the copied circle 2 units in the X direction.", , "Copy Example"
    
    ' Move the circle and color it
    copyCircleObj.Move point1, point2
    
    ZoomAll
    MsgBox "Move completed.", , "Copy Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Copy()
    ;; This example creates a circle and then copies
    ;; that circle. The new circle is then moved.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))    
    
    ;; Create the circle
    (setq center (vlax-3d-point 2 2 0)
          radius 0.5)
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq circleObj (vla-AddCircle modelSpace center radius))
    (vla-ZoomAll acadObj)
    (alert "Copy the circle.")
    
    ;; Copy the circle
    (setq copyCircleObj (vla-Copy circleObj))
    
    ;; Define the points that make up the move vector
    (setq point1 (vlax-3d-point 0 0 0)
          point2 (vlax-3d-point 2 0 0))
        
    (alert "Move the copied circle 2 units in the X direction.")
    
    ;; Move the circle and color it
    (vla-Move copyCircleObj point1 point2)
    
    (vla-ZoomAll acadObj)
    (alert "Move completed.")
)