Grasshopper

algorithmic modeling for Rhino

Hi all,

in a C# component, I have to replace the geometry data into a Rhino object.

Currently I use a switch on the geometry's ObjectType property to call the appropriate

ObjectTable's Replace( Guid,XXX ) method, but I also see there a

Replace(ObjRef,RhinoObject) method that would let me write simpler code.

Is there a way to use this method ?

I wouldn't know how to build a new RhinoObject instance from a GeometryBase instance...

Or has the current way (switch etc.) to be preferred ?

Thanks

emilio

Views: 4047

Replies to This Discussion

bump. How do you get a rhinoobject from a grasshopper object or geometrybase or brep or anything?

All data in Grasshopper has to derive from IGH_Goo. That is why you will never find any Framework types (System.Int32, System.Double, System.String) nor any RhinoCommon types (Rhino.Geometry.Brep, Rhino.Geometry.Point3d) stored directly.

Grasshopper provides wrapper classes for all these types. Depending on the type safety of your data, you can either access the Brep data directly, or you can use one of the many conversion methods in Grasshopper.Kernel.GH_Convert.

If you have data that you know is a brep, then you can cast the goo to GH_Brep. Then access the Value property to get access to the Rhino.Geometry.Brep inside the GH_Brep.

RhinoObject is specifically for objects inside a 3DM file. A RhinoObject contains attributes and user data as well as geometry. Grasshopper only deals in pure geometry. So you'll have to 'bake' the Grasshopper data before you can get it as RhinoObjects.

--

David Rutten

david@mcneel.com

Tirol, Austria

Is it possible to get information like layer and material from grasshopper objects?

Sometimes. If the Grasshopper Data is aware that it is tied to a Rhino object, then it will have the ID of that object. You can then go into Rhino, find the object with the relevant ID and extract the layer and colour and linetype information.

--

David Rutten

david@mcneel.com

Tirol, Austria

David,

It would be very helpful to see a simple example of this in code if possible.  I'm connecting this issue to the thread stated a couple of days ago because I'm still not finding any success with selecting an original instance of geometry.

Basically I have a brep in grasshopper that should link to it's rhino brep - but am having no luck writing code that ties the two instances together so that the rhino instance can be saved out into a 3ds file.

Here is the other thread: http://www.grasshopper3d.com/forum/topics/saving-selected-piece-of-...

David,

Problem solved - it was just a REALLY stupid mistake on my part...

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service