Yes, in rhinocommon, geometry objects are created. This has to do with the intricacies of object-oriented programming, where you have classes as blueprints and objects as class instances. Imagine the class being the blueprint of a chocolate factory and the object or class instance as the built factory itself. The class documents how to construct the object so to speak.
rhinoscriptsyntax is a wrapper for rhinocommon, meaning that each of its functions executes rhinocommon code in the background. You can inspect the source code like this:
import rhinoscriptsyntax as rs
print inspect.getsource("rs.AddPoint") # outputs the source code of this function
rhinoscriptsyntax was meant to make Python scripting in Rhino easier, but it’s debatable if that strategy really came to fruit, especially because every beginner, me included, is always confused about GUIDs.
Now, I don’t know if this is 100% how this really works, but I imagine that GUIDs are like adresses that point to where the geometry in question is stored in your computers memory. This probably has to do with memory management and stuff like that.
Yes, you can for instance use
rs.coercebrep(guid) to get the brep in question. There are also others, but I believe these functions are not documented, because they are probably not meant to be used.
Simply don’t mix rhinocommon and rhinoscriptsyntax and you probably won’t have to deal with coercing.
It’s C# code, but you can mostly treat it like Python. You’re probably not accustomed to what you see because you don’t understand classes yet.
Your code above in rhinocommon could look something like this:
import Rhino.Geometry as rg
def generate_polygon(point, radius, segments):
polyline = rg.Polyline() # construct a Polyline object
angle = (2 * math.pi) / segments # angle in radians
vector = rg.Vector3d.XAxis * radius # construct a Vector3d object
for _ in range(segments):
vector.Rotate(angle, rg.Vector3d.ZAxis) # rotate the existing Vector3d object
polyline.Add(point + vector) # add a point to the existing Polyline object
return rg.PolylineCurve(polyline) # construct a PolylineCurve object from the Polyline object and return it
a = generate_polygon(rg.Point3d.Origin, 12.0, 5)