Mirror Method (ActiveX)

Creates a mirror-image copy of a planar object around an axis.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.Mirror(Point1, Point2)
object

Type: All drawing objects, AttributeReference, Dimension

The objects this method applies to.

Point1

Access: Input-only

Type: Variant (three-element array of doubles)

The 3D WCS coordinates specifying the first point of the mirror axis.

Point2

Access: Input-only

Type: Variant (three-element array of doubles)

The 3D WCS coordinates specifying the second point of the mirror axis.

Return Value (RetVal)

Type: Object

This object can be one of any drawing object and is the result of mirroring the original object.

Remarks

The two points specified as parameters become the endpoints of a line around which the base object is reflected.



Selected object



Point1 and Point2 specifying the mirror axis



Mirrored object

This method places the reflected image into the drawing and retains the original object. To remove the original object, use the Delete method.

You can mirror a Viewport object in paper space, although doing so has no effect on its model space view or on model space objects.

AutoCAD checks to see if the object to be copied owns any other object. If it does, it performs a copy on those objects as well. The process continues until all owned objects have been copied.

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.

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: To manage the reflection properties of text objects, use the MIRRTEXT system variable. The default setting of MIRRTEXT is On (1), which causes text objects to be mirrored just like any other object. When MIRRTEXT is off (0), text is not mirrored.


Before mirroring



After mirroring (MIRRTEXT = 1)



After mirroring (MIRRTEXT = 0)

Examples

VBA:

Sub Example_Mirror()
    ' This example creates a lightweight polyline
    ' and then mirrors that polyline.
    
    ' Create the polyline
    Dim plineObj As AcadLWPolyline
    Dim points(0 To 11) As Double
    points(0) = 1: points(1) = 1
    points(2) = 1: points(3) = 2
    points(4) = 2: points(5) = 2
    points(6) = 3: points(7) = 2
    points(8) = 4: points(9) = 4
    points(10) = 4: points(11) = 1
    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    plineObj.Closed = True
    ZoomAll
    
    ' Define the mirror axis
    Dim point1(0 To 2) As Double
    Dim point2(0 To 2) As Double
    point1(0) = 0: point1(1) = 4.25: point1(2) = 0
    point2(0) = 4: point2(1) = 4.25: point2(2) = 0
        
    MsgBox "Mirror the polyline.", , "Mirror Example"
    
    ' Mirror the polyline
    Dim mirrorObj As AcadLWPolyline
    Set mirrorObj = plineObj.Mirror(point1, point2)
    
    ZoomAll
    MsgBox "Mirror completed.", , "Mirror Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Mirror()
    ;; This example creates a lightweight polyline
    ;; and then mirrors that polyline.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Create the polyline
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 11)))
    (vlax-safearray-fill points '(1 1
                                  1 2
                                  2 2
                                  3 2
                                  4 4
                                  4 1
                                 )
    )
  
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq plineObj (vla-AddLightWeightPolyline modelSpace points))
    (vla-put-Closed plineObj :vlax-true)
    (vla-ZoomAll acadObj)
    
    ;; Define the mirror axis
    (setq point1 (vlax-3d-point 0 4.25 0)
          point2 (vlax-3d-point 4 4.25 0))
        
    (alert "Mirror the polyline.")
    
    ;; Mirror the polyline
    (setq mirrorObj (vla-Mirror plineObj point1 point2))
    
    (vla-ZoomAll acadObj)
    (alert "Mirror completed.")
)