Developer: RhinoScript
Summary: Demonstrates how to create a Globally Unique Identifier (GUID) in RhinoScript.
We have items that we need to track using unique identification numbers. My boss suggested that we use GUIDs for this purpose, just like Rhino does. Is there any way to create a GUID using a script?
There is actually a very easy way to generate GUIDs. The Scriptlet.TypeLib object includes a method that generates GUIDs. If you need a GUID, here is a short script that will supply you with one:
' Creates a Registry-formatted GUID string ' Ex: {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} Function CreateGuidRegistryFormat Dim objTypeLib Set objTypeLib = CreateObject("Scriptlet.TypeLib") CreateGuidRegistryFormat = Left(objTypeLib.Guid, 38) End Function
If you want to create a plain GUID - one without the surrounding curly brackets, then you can do something like this:
' Creates a plain-formatted GUID string ' Ex: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Function CreateGuidPlainFormat Dim objTypeLib Set objTypeLib = CreateObject("Scriptlet.TypeLib") CreateGuidPlainFormat = Mid(objTypeLib.Guid, 2, 36) End Function