I’m writing a grasshopper component that synchronizes information between Rhino and Illustrator. A big part of that is keeping the selection between the two programs the same, so I’ve been trying to use the events exposed in the RhinoDoc Class here to trigger updates:
RhinoDoc.DeselectObjects -= (sender, e1) => OnSelectionDecrease(sender, e1, sendBool); RhinoDoc.DeselectObjects += (sender, e1) => OnSelectionDecrease(sender, e1, sendBool); RhinoDoc.SelectObjects -= (sender, e1) => OnSelectionIncrease(sender, e1, sendBool); RhinoDoc.SelectObjects += (sender, e1) => OnSelectionIncrease(sender, e1, sendBool); RhinoDoc.DeselectAllObjects -= (sender, e) => OnSelectionReset(sendBool); RhinoDoc.DeselectAllObjects += (sender, e) => OnSelectionReset(sendBool); RhinoApp.Idle -= (sender, e) => OnIdle(sendBool); RhinoApp.Idle += (sender, e) => OnIdle(sendBool);
I’m using this project to learn C#, so I’m still getting a feel for the best way to implement things. With the current setup above, I cache information about the changes with the top 3 functions as their events fire. Once Idle fires, Illustrator processes the files and updates. This works most of the time!
The issue I’m having is when I select a new piece of geometry when one is already selected (not shift-click). The selection completely changes, but at no point is the selection empty. Based on how Illustrator reacts, “SelectObjects” seems to be the only event that fires even though the first selection has been removed. It will add the new selection but not remove the deselection.
I guess the short version of my problem: does the DeselectObjects event trigger if the current selection is replaced by a new one? Objects are being deselected but my setup isn’t reacting to that event.
I can share more code specifics if needed! Just have to clean it up to make sense, hoping this is enough context.
Edit: Tested a bit more. Guessing that DeselectObjects fires, then SelectObjects, and then Idle. My setup only catches the most recent change, which would explain why the deselection isn’t registering. Still, even if it’s not being read, no data is being recorded by the DeselectObjects event…