algorithmic modeling for Rhino
I have searched and search and tried and tried but I feel like I am losing my mind. How the heck do retrieve object data using python in Grasshopper?
For example, I am referencing lines with names from Rhino into Grasshopper. How do I retrieve the name using Python and RhinoCommon within Grasshopper? It seems like it should be straight forward.
Thanks!
Tags:
Hi Ryan
the reason you are experiencing difficulties is that Grasshopper does not keep track of what is called 'Attributes' information from the Rhino document. It is still possible to retrieve it, but it means bypassing usual Grasshopper logic and obtaining information from object IDs.
You need to use the Guid component for that. I just googled this post, please let me know if it is not useful enough or too outdated.
Thanks!
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Giulio,
All these solutions work if you already have the ID (GUID) but the question is how to find the ID of a referenced object in Python?
We had a discussion here while ago. I was unable to find a solution that works in GHPython component. Maybe you know why it is happening and how to solve it.
Thanks,
Mostapha
Hi Mostapha,
for sure, if one Guid is available, you could pass the geometry thorugh a Guid component and retrieve it with 'No hint' (or str). Note: Grasshopper does not store this data across components so there's nothing to do in several cases.
Or there could for sure be the option to have a "Guid" hint that does the same as the Guid hint in the C#/Vb component; I would rather stay away from that in order not to have people confused between ghPython-Guids and RhinoDoc-Guids, but otherwise, would that be useful?
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
Hi Giulio,
I understand that Grasshopper doesn't keep track of the properties. I personally think having the RhinoDoc-GUIDs will be useful in many cases. In my case I needed to have access to Layer name, and Object name.
I eventually used the trick that you are showing above and it worked well however I was hoping that I can just write a function inside a component that gives me the RhinoCommon ID's.
Thanks,
Mostapha
The method above is not really a trick. It's rather equivalent to what Grasshopper does when we set the hint to 'Guid' in C#/Vb.Net.
So, the component behaves like the rest of the scripting components on this matter. It just does not have that one hint. Do you think that adding a new Guid hint would not be confusing? It can be done, for sure.
Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com
I agree that two different 'Guid's can be confusing. At the same time having access to RhinoCommon Guid is really useful.
What if you don't add it as a hint but make it accessible somehow from the IDE itself? Something like: anyRhinoObject.GetRhinoGuid()?
Is this possible or RhinoCommon Guid is already gone when geometry passes the input of the GHPython component?
Mostapha
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by