Grasshopper

algorithmic modeling for Rhino

Hi! I want to make a small component that returns a boolean if current geometry is selected in rhino. 

I found this "isselected" comand in Rhinocommon,

but did not understand how make it works. Please, give me a clue how to deal with it or a link to example.

What i want to do is to feed this component with geometry ID`s and have a list of boolean answers.

Thnx in adwance

Views: 543

Replies to This Discussion

Hi Philipp,

you want the component to update when a selection changes? Because that involved event handling as well.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

David, thank you very much, that exactly what I wanted! Now I can visualise information separately and design an interface mixing this component with firefly "if button pushed"

but what means "<> 0"  in the last line   selected = obj.IsSelected(False) <> 0 ???

Think it is a good idea to add something like this (maybe there is a way to speed it, now it a bit slow) to Firefly...

IsSelected() returns a number of possible integers:

0 = object is not selected.

1 = object is selected.

2 = entire object is selected persistently.

3 = one or more proper sub-objects are selected.


So the <> 0 means, "if the IsSelected method returns anything other than zero, then we assign TRUE to the component output."

In my opinion this should never have been an integer, but rather an enumeration. However, changing it now means breaking the RhinoCommon SDK.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi David,

Thanks for this piece of code its also very useful to me however I noticed it only works when you click on the Grasshopper canvas - re-compute is there is a way to make it so I don't need to do this?

If you want to respond to selection events in Rhino then you'll need to handle those events. You'll need to look at the RhinoDoc.DeselectAllObjects, RhinoDoc.DeselectObjects, and RhinoDoc.SelectObjects events.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service