Grasshopper

algorithmic modeling for Rhino

I am trying to get layer names of referenced geometry.

 

I know I could just create an input, set the type to guid and be on my way, but I want to know how to grab the guid within the code body.

 

I looked around for this a little bit, but couldn't find anything.

 

Matt

Views: 6700

Replies to This Discussion

Like so?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

Sorry David, but this is exactly what I wasn't looking for!

 

I am in the process of developing components which have a high number of inputs.  If I can avoid a separate input for the GUID, then I am very happy.  If not, then I guess I need another input.

 

It looks like most of the classes in the Rhino.Geometry namespace do not have properties for exposing the ObjectID.  Is this right?

 

The RhinoCommon SDK shows a lot of properties for exposing the ID within the Rhino.DocObjects namespace.  For example; the PointObject class has an ID property.  Since I am referencing object in the rhino document, I assume I would be able to do this within the script code, but maybe this isn't the case.

 

I noticed there is a PointConverter in the System.Drawing namespace, but I don't know how this works...

 

 

This seems like it should work, but I cannot convert a Point3d into a PointObject, or a Curve into a CurveObject.

(ByVal x as Point3d...

    Dim sGUID As System.Guid

    Dim y As Rhino.DocObjects.PointObject = x
    sGUID = y.Attributes.ObjectId

    A = sGUID.ToString

 

 

I hope I am describing this in the correct technical terms; I am still a bit new to scripting / programming.

In a VB/C# script component this is not possible. The Reference ID is stored inside types such as GH_Brep, GH_Curve, GH_Mesh etc., but those are not accessible to the script itself. If you want access to both the geometry and the reference data, you'll need to write a GHA library with actual compiled components.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Sorry David, but things are still a bit murky.  Once the rhino document curve is referenced within grasshopper, then the Reference ID is stored within the GH_Curve class?

 

I expected that since I am referencing a rhino document object, that the information for that object Id would reside somewhere within the docObjects class.  What you are telling me is; once the document object is referenced within Grasshopper (i.e. 'Select One Point'), the object ID is only accessible through it's respective GH_ geometry class.

 

Is that right?

 

It looks like I will have another input until I learn to compile proper gha components.  Schade!

 

Thanks!

The GH_Curve type basically works like this, it has 3 local variables:

Dim referenceID as Guid

Dim referenceEdge as Integer

Dim curve As Curve

If referenceID does not equal Guid.Empty, then the curve is assumed to reference a curve object in a Rhino document. That object might not exist, so the reference might be invalid, but it is still assumed to be a reference.

If referenceEdge is not -1 and referenceID is not Guid.Empty, then the curve is assumed to be an edge in a referenced Brep. 

If referenceID equals Guid.Empty, then the curve is assumed to be non-referenced.

When a GH_Curve (with all the above data) is plugged into a script component, then it takes the curve member and it creates a shallow-duplicate of it. A shallow duplicate is a special kind of RhinoCommon duplicate that doesn't actually duplicate the curve until you change it. So it's a cheap way (low on cycles and memory overhead) to get multiple instances of the same curve that can not affect each other. However this duplication removed all reference data and only leaves you with the curve geometry. 

There is no way around this, except specifically getting a Guid input parameter.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Makes sense.  Thank you for the detailed explanation.

 

So, GUID input it is...

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service