Copying Objects

Use the Copy method to copy an existing drawing object. The new object occupies the same position as the original object and is drawn on top of all other objects. This method has the following syntax:

Set DrawingObject = DrawingObject.Copy

The following code asks the user to pick a drawing object from the screen. It then copies the object and moves it to a point the user chooses.

Public Sub CopyObject()

Dim objDrawingObject As AcadEntity Dim objCopiedObject As Object Dim varEntityPickedPoint As Variant Dim varCopyPoint As Variant

On Error Resume Next

ThisDrawing.Utility.GetEntity objDrawingObject, varEntityPickedPoint, _

"Pick an entity to copy: " If objDrawingObject Is Nothing Then MsgBox "You did not pick an object" Exit Sub End If

'Copy the object

Set objCopiedObject = objDrawingObject.Copy()

varCopyPoint = ThisDrawing.Utility.GetPoint(, "Pick point to copy to: ")

'put the object in its new position objCopiedObject.Move varEntityPickedPoint, varCopyPoint objCopiedObject.Update

End Sub

0 0

Post a comment