Hi,
I am really stuck in this problem and couldn’t find why it is happening after many debuggings. It is happening in both Rhino and Eto.Forms events.
I know it is hard to understand without seeing whole code but, maybe you know why it is potentially happenning.
I have some lists that MyPlugin handle it’s operations with them and I am cleaning this list after deselection.
// Registration method for constructor
private void RegisterControlEvents()
{
RhinoDoc.SelectObjects += RhinoDoc_OnSelectObjects;
RhinoDoc.DeselectAllObjects += RhinoDoc_DeselectAllObjects;
}
// Sample of handler
private void RhinoDoc_DeselectAllObjects(object sender, RhinoDeselectAllObjectsEventArgs e)
{
SelectedPluginObjects.Clear();
SelectedCurves.Clear();
}
PS: I am sure, there is no another subscription for this event
What am I missing?
Thanks in advance
Hi @oguzhankoral,
If you are trying to maintain lists of objects based on selection or deselection, it is better to handle it in Rhino.Idle handler. For example,
private void OnIdle(object sender, EventArgs e)
{
//For example you want to get the list of all selected curves
var selectedCurveObjects = RhinoDoc.ActiveDoc.Objects.GetObjectsByType<RhinoObject>(new ObjectEnumeratorSettings() { ObjectTypeFilter = ObjectType.Curve, SelectedObjectsFilter = true }).ToList();
//Update your lists
}
1 Like
Hi @Darryl_Menezes,
It is good to know this way for me, thanks for your help. I tried your way, but event works like infinite loop, do you estimate why possibly it is happening?
Well, the event is fired everytime Rhino is Idle, so basically almost all the time. But this shouldnt be an issue as long as you get your lists right.
@Darryl_Menezes,
I can manage list easliy with this way now. It is really better instead of using below events;
RhinoDoc.SelectObjects += RhinoDoc_OnSelectObjects;
RhinoDoc.DeselectAllObjects += RhinoDoc_DeselectAllObjects;
Appropriate for your help, you saved my many time,
Although still I don’t know why Selection and Deselection events were triggering twice, this Idle event solved my problem.
Thanks
-Oğuzhan