Grasshopper

algorithmic modeling for Rhino

General question about UserDictionary and ghenv.Component.InstanceGuid

This is a general question Im just hoping to improve my own understanding

I've noticed these two pieces of code in some components created in the Honeybee project.

geometry.UserDictionary.Set('HBID', key) and 

ghenv.Component.InstanceGuid

as well as the line of code str(uuid.uuid4()))

Firstly what is UserDictionary and why would I use it and not the sticky?

Secondly what does the following lines of code do?

ghenv.Component.InstanceGuid  and

str(uuid.uuid4()))

Where can I find more information about these lines of code is it in rhino commons?

Views: 1749

Replies to This Discussion

we have discussed userdictionary and userdata much before,But unfortunately they have been deleted by ning--

Hi Anton,

ghenv.Component.InstanceGuid returns guid of your python component. Like geometry objects, grasshopper components have guids too.

As for UserDictionary, it's meant to attach some data (a string, geometry, material...) to a particular geometry, layer, attributes...
But it seems that currently it only supports instances of the classes derived from CommonObject class. So in python, you better use sticky dictionary as Mostapha pointed out in the upper link, as it's universal, and can accept anything, from geometry to functions, classes...


Not sure about the third one: str(uuid.uuid4())), it's probably question for Mostapha.

As for the help info, look at RhinoCommon SDK pages and Grasshopper SDK help file ("Help-> Download SDK Help" in your Grasshopper application menu)

djordje as always thanks for being so helpful

Djordje when you mean guid do you mean a Globally Unique Identifier?

Yes.
Guid, uuid, and id are all often used to describe the same thing.

Thanks David, do you know the significance of the line of code:

str(uuid.uuid4()))? How is uuid difference from guid?

It isn't, they are the same thing. C++ uses "uuid", python may as well. .NET uses Guid.

Djordje answered it all.

Back to uuid here you can read more > http://en.wikipedia.org/wiki/Universally_unique_identifier

I generate a unique uuid for each Honeybee object and attached them to geometry so I can call them in other components downstream.

Mostapha

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service