The Rhino.IsObject(strID) always returns false if I manually set strID to a valid ID as returned by Rhino’s List command. For instance:
strID = “FF628557-9C20-403e-AE70-9A3EF6C312EE”
if IsObject(strID) then 'always returns false!
I’m outputting object data to a text file including the IDs, and through a Rhinoscript dialog allowing the user to paste in an ID to select it. There seems to be more than just text associated with a valid ID string though. I’ve also tried the ID as all lower and all upper case, but neither works. How do I format it as a recognizable object ID?
A GUID is a 128-bit structure. The normal string representation uses 32 hex digits to represent the 32 nibbles in the structure, and is not
case-sensitive.
Have you tried Guid.Parse?
I can not reproduce your problem, can you upload the file containing the object?
Are you suggesting to use something like:
sstrID = Guid.Parse(“FF628557-9C20-403e-AE70-9A3EF6C312EE”)
Yes.
But it should work with string representation of GUID too.
I tried this in my RhinoScript code, but it causes a syntax error:
strID = guid.parse(“FF628557-9C20-403e-AE70-9A3EF6C312EE”)
Are you suggesting to reformat the string using braces instead of hyphens?
You need to first import System.Guid
. I don’t know about Rhinoscript but in Python it must be something like this:
import System
import rhinoscriptsyntax as rs
strID = "FF628557-9C20-403e-AE70-9A3EF6C312EE"
print rs.IsObject(System.Guid.Parse(strID))
Could find anything described anywhere, so I wrote a brute force routine. It’s ugly but it works:
Function GetObjectGUID(strFindID) 'GUID is a specially formatted string = Globally Unique Identifiers
'Turns a txt string identifier into a valid object GUID string
'Returns Null if not found
Dim strID
Dim AllRhinoObjects
GetObjectGUID = Null
AllRhinoObjects = Rhino.AllObjects(False, False, False)
If IsArray(AllRhinoObjects) Then
For Each strID In AllRhinoObjects
If Rhino.IsObjectValid(strID) Then
If lcase(strID) = lcase(strFindID) Then
GetObjectGUID = strID
Exit For
End If
End If
Next
End If
End Function