Grasshopper

algorithmic modeling for Rhino

Hi,

i'm trying to make a Custom Component in Grasshopper. 

what i'm trying to do now is get object's layer from input geometry

i've made it, but one thing i don't like is that i have to input an object's GUID, not an object itself.

this is what i made,

Rhino.DocObjects.ObjRef oRef = new Rhino.DocObjects.ObjRef(new Guid(id));
Rhino.DocObjects.RhinoObject o = oRef.Object();
string objLayer = RhinoDoc.ActiveDoc.Layers[o.Attributes.LayerIndex].Name;

is it possible to input object and get a layer name? i can't find anything in rhinocommon and grasshopper sdks.. 

Views: 4345

Attachments:

Replies to This Discussion

Hi Taehyuk,

if you ask for IGH_GeometricGoo data you can get access to both the geometry and the id. See the attached file. Note that Grasshopper does not update itself when a referenced object has an attribute change, it only responds to geometry changes.

Also note that curves and points can have more complex reference data. Curve ReferenceID may refer to a Brep, in which case there will be an additional member to identify the edge index. Points are way complex. If you want to handle these types correctly you'll need to check for them and cast them accordingly.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

Thanks David!

This is exactly what i'm looking for! :)

Hi David,

   Is it possible for us to get this:

                    Guid id = goo.ReferenceID;

   work in grasshopper script C# comonent but not the built and compiled one?

   Thank you!

Yijiang

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service