Moving Objects

Use the Move method to perform three-dimensional translations on drawing objects. This method has the following syntax:

DrawingObject.Move Point1, Point2

Table 10-3 explains this method's parameters.

Table 10-3. Move Method Parameters

Name

Data Type

Description

Point1

Variant

A three-element array of doubles specifying the 3-D WCS coordinates of the translation vector's starting point.

Point2

Variant

A three-element array of doubles specifying the 3-D WCS coordinates of the translation vector's ending point.

Figure 10-3 shows an object moved from one place to another.

Figure 10-3 shows an object moved from one place to another.

Pointi

Figure 10-3. A moved object

The following example shows how to implement this method. The user first picks a selection of objects to be moved and specifies the translation vector on the screen.

Public Sub MoveObjects()

Dim varPoint1 As Variant Dim varPoint2 As Variant Dim objSelectionSet As AcadSelectionSet Dim objDrawingObject As AcadEntity

'choose a selection set name that you only use as temporary storage and 'ensure that it does not currently exist On Error Resume Next

ThisDrawing.SelectionSets("TempSSet").Delete

Set objSelectionSet = ThisDrawing.SelectionSets.Add("TempSSet")

'ask user to pick entities on the screen objSelectionSet.SelectOnScreen varPoint1 = ThisDrawing.Utility.GetPoint(, vbCrLf _

& "Base point of displacement: ") varPoint2 = ThisDrawing.Utility.GetPoint(varPoint1, vbCrLf _ & "Second point of displacement: ")

'move the selection of entities For Each objDrawingObject In objSelectionSet objDrawingObject.Move varPoint1, varPoint2 objDrawingObject.Update Next objSelectionSet.Delete End Sub

Was this article helpful?

0 0

Post a comment