G’day, I’m sure there is a simple solution to this problem.
I’d like to mirror objects across a vessel centreline, coincident with X-Axis, ZX Plane. This script works in Top and Perspective Views, but mirrors vertically across XY Plane otherwise.
Can anyone suggest an alternative method to mirror across a plane?
import rhinoscriptsyntax as rs
def mirrorCL():
# Get some objects and mirror them across centreline
# World 0,0,0 is origin and X axis mirror plane.
strGeometryID = rs.GetObjects("Please select a part to mirror across CL",0,True,True)
if strGeometryID:
rs.MirrorObjects(strGeometryID, [0,0,0], [10,0,0], True)
if __name__=="__main__":
mirrorCL()
IIRC, rs.MirrorObjects() uses the active CPlane. That’s why it works in Top and Perspective as you think it should, but not elsewhere. If you want to force World ZX mirror plane, you could use the following:
import rhinoscriptsyntax as rs
def mirrorCL():
# Get some objects and mirror them across centreline
# World 0,0,0 is origin and X axis mirror plane.
geo_IDs = rs.GetObjects("Please select parts to mirror across CL",0,True,True)
if geo_IDs:
#Create a mirror transformation using world origin and X axis as mirror plane normal
xform=rs.XformMirror([0,0,0],[1,0,0])
#transform your objects using the transform created above
mirr_objs=rs.TransformObjects(geo_IDs,xform,True)
mirrorCL()
HTH, --Mitch
PS watch your GetObject(one_object) vs GetObjects(multiple_objs)…
Pascal did a simple command ages ago when I requested this for mirroring my yacht models across the x axis which I assigned to the keyboard shortcut Ctr;+F.
Paste this in,
! _Mirror _Pause 0,0,0 1,0,0`
Seems like it would be quicker that calling up Python script. Maybe I don’t understand how a script would improve on the keyboard shortcut.
Thanks @jodyc111 , the reasons for the simple script is so that I can bundle a few useful scripts together as a plugin for the office and so that I can learn Python.
I had an extra ' at the end earlier. I have always had the x axis as the centerline of any marine designs since a boat is usually longer than it is wide and fits the screen better that way. So my mirror shortcut is across the y axis.