Grasshopper

algorithmic modeling for Rhino

Is every definition having a unique ID I can add to variables when using sticky? Just found this and in sc just Path and Name, but not an ID.

UniqueID
E:\test.gh

UniqueID_2bf5abb25e4d38232b2467e8dd94fbb3

My workaround is probably safe enough for me, but I am still curious since everything in GH seem to have its' own GUID.

Views: 570

Replies to This Discussion

'definition'? You mean every GH_Document?

GH_Document has a DocumentID readonly property. This ID is set when a document is created anew, and it will be restored when a document is read from a file. However, there are ways the ID can change after a document has been created, most notably when it is inside a cluster object.

--

David Rutten

david@mcneel.com

Hi Marcus

for what are you needing this unique ID, in sticky? What would you like to store there?

Thanks,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
Giulio@mcneel.com

Using the filename or the save path of a document is not necessarily a good way. Files can be renamed and moved to different folders, but these actions will not change the DocumentID. It is also possible that a GH_Document has no filename or folder associated with it, if it has never been saved.

On the other hand, if you copy a file in explorer, you get two documents with the same DocumentID which can both be loaded at the same time.

Grasshopper uses the ID solely for cluster management. Clusters that contain documents with identical IDs are 'entangled'.

--

David Rutten

david@mcneel.com

I would really suggest to "stick" to hidden cables, if possible for your purpose. It's better to use the official & suggested way in Grasshopper, unless what you are trying to do it not possible that way.

If, in the future, you or somebody else will need to see the ID of the document, they can do it this way in Python:

ghcanvas = ghenv.Component.OnPingDocument()
a = str(ghcanvas.DocumentID)

--

In C#

A = GrasshopperDocument.DocumentID.ToString();

--

In Vb.Net

A = GrasshopperDocument.DocumentID.ToString()

Thanks,

Giulio

--

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

What is sticky?

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