I would be grateful if someone could explain when a GUID is created…I understand any GetObject will create one but does the resulting creation inn a script have one ? For example, if I have a definition of a Triangle as a sequence of events and then call Triangle, does the resulting Triangle automatically have a GUID , and if my script then creates a surface from that triangle does the resulting surface have a GUID ?
I am asking because I have successfully created the surface and rotated it but even though the rotation is successful I get an error message:
This following works fine and the surface is rotated ;
C = rs.GetObject(‘pt 3’)
rs.Command("_SelSrf")
Tri = rs.GetSurfaceObject( preselect=True)
rs.RotateObject(Tri,C,30)
however this message pops up:
Message: The <type ‘bool’> cannot be tranformed. A Guid or geometry types are expected.
I think this means that the surface created in my script earlier and selected by SelSrf has been accepted as Tri because I identified it as preselected but it still does not have a GUID. Am I correct in my understanding, and why has it performed the transformation despite saying that it cannot do it ?
No any object that is created gets an id. Pay attention to what functions return, getsurfaceobject spits out an array of stuff not just the id.
so I needed to make it look for the first option in Tri…namely Tri[0] to force it to only look at the GUID…thanks for the hint.
Just to offer some more explanation relative to the title of this topic i.e.
“When is a GUID greated?”
Every object in a Rhino document has a GUID - an alphanumeric string that uniquely identifies it. Associated with the object’s GUID are all of the object’s characteristics such as geometry, layer, color, etc… GUID’s are what allow Rhino to keep track of everything, they are stored in various tables such as the object table, the layer table, etc.
Everything that already exists in a Rhino document before you run a script therefore already has a GUID. When you use one of the selection methods like GetObject()
to pick an existing object, it returns the GUID of the object selected.
Many rhinoscript methods add objects to the document. At the moment the object is added to the file, a new GUID is assigned to it. Most often the method that added the object returns the GUID of the object it just created so that you can keep track of it and access it later in the script.
new_line=rs.AddLine([0,0,0],[10,0,0])
will add a line to the document and the variable new_line will contain the GUID of the line just added.
Methods that create multiple objects will return a list of GUID’s (generally)
Not all rhinoscriptsyntax methods return GUID’s though, for example AddLayer()
returns a string that is the layer name. Some return numbers or Boolean values True
or False
. When in doubt, always consult the rhinoscriptsyntax help for what the method wants as arguments and what it returns.
So my error message refers to the boolean option copy=True which is why I need to isolate the first GUID option Tri[0]
thanks for the clear explanation