Hey all,
Im writing on a GHPython script in Rhino 5 that I want to re-run when objects in the active rhino doc are transformed (moved or rotated mainly). I managed to get this to work (but not efficiently) using the following code that @AndersDeleuran posted on the forum a while ago:
def addRhinoDocEvent(sender,e):
""" Update this GH component """
ghenv.Component.ExpireSolution(True)
#Check to see if the callback is already assigned
if "eventID" not in globals():
# # Instance of function to call on event
eventID = addRhinoDocEvent
# # Assign function to a rhino doc event. 'AddRhinoObject' appears to trigger events for object transformations as well?
Rhino.RhinoDoc.AddRhinoObject += eventID
My main issue with the code is that if i move or rotate several items at once in the active rhino doc, the GH script is ran once for every event flag. Ideally it should only run once.
Is there something like a queue for commands that I can access to see all the coming actions to the Rhino doc or possibly some way to check when there are no events/idling (seems RhinoApp.Idle and RhinoDoc.AddRhinoObject are independet of one another?) Also if anyone has a tip on how I can wait for say 1ms to see if any more events happen, and if not rerun my component after that?
Very greatful for any pointers on how to approach this and/or where I can find more information on how to work with events in Rhino!
Best
/ Jakob