Grasshopper

algorithmic modeling for Rhino

Hi All, I'm trying to write a module that when you plug in a curve it will output the layer name that curve is on.

 

I've looked at the code on the SDK site (http://wiki.mcneel.com/developer/sdksamples/objectlayer) and it makes sence but I don't really know how to go from an OnCurve to and IRhinoObject.

 

Not sure how to type cast an oncurve to an irhinoobject.

 

Any help would be great

Thanks

Charlie

 

Views: 1309

Replies to This Discussion

Hi Charlie,

you can't go from OnCurve to IRhinoCurveObject. An IRhinoCurveObject contains a curve and a set of attributes. Which layer owns the object is defined in the Attributes. Geometry which is generated inside Grasshopper doesn't have attributes.

What you could do is not get a curve but get an Object Identifier (Guid) as an input. If the curve is referenced, then it will convert itself into a Guid automatically. Then you can ask the currently active Rhino document whether it is familiar with the Guid in question and if it is, you can get the IRhinoCurve object from the document and access the attributes.

Do note that Grasshopper 0.7 and beyond is build on the RhinoCommon SDK, so the types RMA.OpenNurbs.ONCurve and RMA.Rhino.MRhinoObject are no longer available. RhinoCommon uses different classes with different names and different layouts.

I'll write an example script after I fix a few more data casting errors.

--
David Rutten
david@mcneel.com
Seattle, WA
See attached for 'Reference Curve -> Guid -> Layer Name' logic.

--
David Rutten
david@mcneel.com
Seattle, WA
Attachments:
That makes sence. It works perfect,
Thanks
[C]

David;

 

Your script is very useful to me. But I need something extra. Can you just sightly modify that script such that it takes  as an object instead of LAYER. Pls check my snap. I highlighted what I mean.

 

Thnx

On a related but tangential discussion, is there a RhinoCommon replacement for the DataCRC function that used to exist in the old SDK? It was a really quick way to do duplicate checks (and there by duplicate elimination as well)... it's fairly easy to do a Duplicate check on simple geometry types, but it can be super tedious and slow for Surfaces/Meshes/Breps..
Yeah I've run into this myself as well. Since it's only ever used for duplicate tests, I'll ask around to see if we might have a better solution for this.

--
David Rutten
david@mcneel.com
Seattle, WA

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