Hello
I am trying to make a button that mirrors a object in X or Y axis.I have a script that mirrors x and y axis.would it be possible to have a button that asks if I want to mirrors x or y axis after clicking the button.below is the script
Call MirrorXY()
Sub MirrorXY()
Dim hState,objs,xMirObjs,yMirObjs
hState = Rhino.EnableHistoryRecording(True)
objs = Rhino.GetObjects("Select objects to quad mirror",,, True, True)
Call Rhino.EnableRedraw(False)
If Not IsArray(objs) Then Exit Sub
Call Rhino.Command("_Mirror X _Enter", False)
xMirObjs = Rhino.LastCreatedObjects()
If IsArray(xMirObjs) Then
Call Rhino.SelectObjects(xMirObjs)
Call Rhino.Command("_Mirror Y _Enter", False)
End If
Call Rhino.UnselectAllObjects()
Call Rhino.SelectObjects(objs)
If Not hState Then
Call Rhino.EnableHistoryRecording(False)
End If
Call Rhino.EnableRedraw(True)
End Sub
)
You could use Rhino.GetBoolean to make your choice…
(edited slightly, added “sticky” axis choice)
Option Explicit
'set up a global variable to remember axis setting within session
Private prevMA
If IsEmpty(prevMA) Then prevMA = False 'default to X
Call HistoryMirrorXorY()
Sub HistoryMirrorXorY()
Dim hState,objs,mirObjs,bool,axis
hState = Rhino.EnableHistoryRecording(True)
objs = Rhino.GetObjects("Select objects to mirror",,, True, True)
If Not IsArray(objs) Then Exit Sub
bool = Rhino.GetBoolean("Mirror axis?", Array("Mirror", "X", "Y"), Array(prevMA))
If IsNull(bool) Then Exit Sub
If bool(0) Then axis = "Y" Else axis = "X"
Call Rhino.EnableRedraw(False)
Call Rhino.Command("Mirror " & axis & " Enter", False)
Call Rhino.EnableHistoryRecording(hState)
'record axis choice for next use
prevMA = bool(0)
Call Rhino.EnableRedraw(True)
End Sub