Generate Unique Strings (like a GUID) in python/common

Hi,

I’m looking for a way to generate a unique serial number (like a GUID) to tag parent/child linkage.
Does anybody know a way to generate these?

-Willem

Check this:
https://docs.python.org/2/library/uuid.html

Example:

import uuid
 #make a UUID based on the host ID and current time
Print uuid.uuid1()
1 Like

Thanks Jordy.
I was looking for a way without importing another module and maybe have it available though Common but for now this will do.

-Willem

You could also use this .NET function (which is probably what the Rhino/GH peeps do I imagine):


import System

g = System.Guid.NewGuid()

print g

1 Like

Anders had the right idea. To convert to string, do this:

import System
g = System.Guid.NewGuid().ToString()
print g
1 Like

Hi Dale,
how can we convert this string again to guid?

Thanks

https://msdn.microsoft.com/en-us/library/system.guid.parse(v=vs.110).aspx