So I’m currently exploring options for making a better user experience for a grasshopper definition I created. What I’m trying to do is a way to detect automatically (inside a c# component) if inside rhino there is a object selected, and return a boolean. This so I can activate a custom visualization for selected objects.
Any ideas or reading material you guys can recommend?
Thanks @farouk.serragedine ! It works! Just one small question… I’ve seen on forums that one must unsubscribe to events before subscribing, should I be concerned about that? Or am I getting the idea wrong?
@csykes I’m not so sure how this should be implemented, sorry but inside which scope should I declare these? Should I declare the functions inside the RunScript Scope? I will try to learn in my own, so don’t worry, but if you can provide a gh file with the c# component to understand the structure, it would help me alot! Anyways, thanks for the input, will update with solution when found!
But make sure you unsubscribe before any code change because this change will create a different OnSelectObjects method so your previous subscripted method will be running forever. As shown above you should unsubscribe before subscribe bc your component may run more than once with enabled=true, so in this way you avoid multiple subscriptions.
You also could get rid of this input by replacing it by an internal variable that you set true once you subscribe, but this is not a good approach if you are developing the code.