Option Explicit
'Script written by Mitch Heynick
'Version Tuesday, January 14, 2014
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
What the script is supposed to do is turn on History if it’s not already on and remember that so it can turn it back off again at the end; but if History is on to begin with, I assume the user doesn’t want to turn it off, so it needs to stay on.
hState = Rhino.EnableHistoryRecording(True)
turns history on, but hState stores the previous condition
There is a bug currently that if History isn’t on, Rhino.EnableHistoryRecording() returns Empty instead of False. So I set up the script to look at what hState is at the end - if it’s anything OTHER than True (this includes both False and Empty), it turns the history back off.
If Not hState Then
Call Rhino.EnableHistoryRecording(False)
End If
This way, when the bug gets fixed, the script will still work…