IsCloned Example

Using Programming Languages other than VBA

Sub Example_IsCloned()
	' This example creates a Circle object and uses the CopyObjects
	' method to copy the Circle. It then displays some information
	' about the source objects used in the CopyObjects operation.

	Dim circleObj As AcadCircle, circleObjCopy As AcadCircle
	Dim centerPoint(0 To 2) As Double
	Dim radius1 As Double, radius1Copy As Double
	Dim objCollection(0 To 0) As Object
	Dim retObjects As Variant
	Dim IDPairs As Variant
	Dim IsClonedState As String, IsPrimary As String, IsXLated As String

	' Define the Circle object
	centerPoint(0) = 0: centerPoint(1) = 0: centerPoint(2) = 0
	radius1 = 5#: radius1Copy = 1#

	' Add two circles to the drawing
	Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius1)
	ThisDrawing.Application.ZoomAll

	' Copy objects
	'
	' First put the objects to be copied into a form compatible with CopyObjects
	Set objCollection(0) = circleObj

	' Copy object and get back a collection of the new objects
	retObjects = ThisDrawing.CopyObjects(objCollection, , IDPairs)

	' Get newly created object and apply new properties to the copies
	Set circleObjCopy = retObjects(0)

	circleObjCopy.radius = radius1Copy
	
	ThisDrawing.Application.ZoomAll
	ThisDrawing.Regen acAllViewports

	' Display whether the first source object has a clone
	IsClonedState = IIf(IDPairs(0).IsCloned, "is cloned.", "is not cloned.")
	IsPrimary = IIf(IDPairs(0).IsPrimary, "is a primary member of the objects being copied.", "is owned by a primary member of the objects being copied.")
	IsXLated = IIf(IDPairs(0).IsOwnerXlated, "has been translated.", "has not been translated.")

	MsgBox "The new Circle source object: " & IsClonedState & vbCrLf & _
		 "The new Circle source object: " & IsPrimary & vbCrLf & _
		 "The source of the new Circle object: " & IsXLated & vbCrLf, vbInformation

End Sub

 

   Comments?