Actually, a Python (or RhinoCommon) Point3d object is NOT a list…
First, one thing to know about Python is that it is an object oriented programming language (sometimes abbreviated as OOP), and the first thing that is usually stated in a Python programming book is “In Python, EVERYTHING is an object”… But what is an object, exactly…?
That can take a whole book chapter to explain, but briefly, objects can have both methods and properties associated with them.
- Properties are easy - it is something intrinsic to the object. If
the object was an apple, its properties might be size, color,
texture, ripeness, etc.
- Methods are things (actions) that you can do with the object. For an
apple that might be pick, peel, cut, eat, throw…
So, a Point3d OBJECT in Python has both methods and properties. They are pretty simple, as a Point3D is not a very complex object.
Some properties of a Point3d would be Point3d.X, Point3d.Y, Point3d.Z which are its coordinates… Some Point3d methods would be addition, subtraction, multiplication and division, but also things like Point3d.ToString() (which does what it says), Point3d.CompareTo(pt) (compare to another point), etc.
Anyway, it’s a bit difficult to wrap your head around (mine’s maybe halfway at this point), but once you get it, it’s pretty powerful. It is a different way of looking at things compared to classic Rhinoscript.
As far as “coerce…” is concerned, the name is actually pretty appropriate - it is attempting to force the creation of an object from something that it is not, but could be with a little effort. One thing to know about the coerce functions is that they can accept different inputs. For example corecepoint3d can not only accept a 3 number list or tuple, it can also accept a Rhino point object in the file (GUID) or a even a string representing a point:
import rhinoscriptsyntax as rs
string = "1,2,3"
list = [1,2,3]
ptObj = rs.AddPoint(1,2,3) #ptObj will be a GUID (object ID)
result = rs.coerce3dpoint(string)
print result, type(result)
result = rs.coerce3dpoint(list)
print result, type(result)
result = rs.coerce3dpoint(ptObj)
print result, type(result)
Hope this answers your questions…
–Mitch