Mirroring Objects

Use the Mirror method to create an object that is the mirror image of an existing planar object. This method has the following syntax:

Set DrawingObject = DrawingObject.Mirror(Point1, Point2)

Table 10-1 explains this method's parameters.

Table 10-1. Mirror Method Parameters

Name

Data Type

Description

Point1

Variant

A three-element array of doubles specifying the 3-D WCS coordinates of a point on the mirror axis.

Point2

Variant

A three-element array of doubles specifying the 3-D WCS coordinates of a second point on the mirror axis.

The following code lets the user choose a selection of objects and a mirror axis, and then mirrors the objects around that axis.

Public Sub MirrorObjects()

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

ThisDrawing.SetVariable "MIRRTEXT", 0

'not required for 2006

'not required for 2006 'not required for 2006

'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

ThisDrawing.Utility.Prompt "Pick objects to be mirrored." & vbCrLf objSelectionSet.SelectOnScreen

'change the highlight status of each entity selected varPoint1 = ThisDrawing.Utility.GetPoint(, _

"Select a point on the mirror axis") varPoint2 = ThisDrawing.Utility.GetPoint(varPoint1, _ "Select a point on the mirror axis")

For Each objDrawingObject In objSelectionSet

Set objMirroredObject = objDrawingObject.Mirror(varPoint1, varPoint2) objMirroredObject.Update

Next objSelectionSet.Delete End Sub

Note that the MIRRTEXT system variable has been set to 0. This setting mirrors text objects to the appropriate place on the drawing, but does not mirror the text itself, as shown in Figure 10-1 The default value of MIRRTEXT in AutoCAD 2004 is 0, but it defaulted to 1 in earlier versions of AutoCAD. If you set MIRRTEXT to 1, the text gets mirrored just as any other object.

Mirrored Objects

/*Point2

Base Objects

This is a text object

Pointl

Figure 10-1. Mirrored objects

Use the Mirror3D method to reflect an object in a plane, where the new object lies outside the plane of the original object.

Set DrawingObject = DrawingObject.Mirror3D(PlanePoint1, PlanePoint2, PlanePoint3) Table 10-2 explains this method's parameters.

Table 10-2. Mirror 3D Method Parameters

Name

Data Type

Description

PlanePointl

Variant

A three-element array of doubles specifying the 3-D WCS coordinates of a point in the mirror plane.

PlanePoint2

Variant

A three-element array of doubles specifying the 3-D WCS coordinates of a second point in the mirror plane.

PlanePoint3

Variant

A three-element array of doubles specifying the 3-D WCS coordinates of a third point defining the mirror plane.

Figure 10-2 shows an object reflected on a plane.

Figure 10-2 shows an object reflected on a plane.

PlanePoint3 /

/ PlanePoint2

PlanePoint3 /

/ PlanePoint2

PlanePointl ~ ^— Mirrored Object

Figure 10-2. A 3-D mirrored object

The following code adds a new drawing object that reflects the base object around the

WCS XY plane.

Public Sub MirrorObjectinXYplane()

Dim objDrawingObject As AcadEntity Dim varEntityPickedPoint As Variant Dim objMirroredObject As AcadEntity Dim dblPlanePointl(2) As Double Dim dblPlanePoint2(2) As Double Dim dblPlanePoint3(2) As Double

On Error Resume Next

ThisDrawing.Utility.GetEntity objDrawingObject, varEntityPickedPoint, _

"Please pick an entity to reflect: " If objDrawingObject Is Nothing Then

MsgBox "You did not choose an object" Exit Sub

'set plane of reflection to be the XY plane dblPlanePoint2(0) = 1# dblPlanePoint3(1) = 1#

objDrawingObject.Mirror3D dblPlanePoint1, dblPlanePoint2, dblPlanePoint3 End Sub

Was this article helpful?

0 0

Responses

  • marco kunze
    How to mirror object in autocad 2006?
    8 years ago

Post a comment