Just ran across an odd phenomenon - don’t know if it should be classified as a bug or not… Run the following:
import Rhino
import scriptcontext as sc
ptA=Rhino.Geometry.Point3d(1,1,1)
pl=Rhino.Geometry.Polyline([ptA,ptA])
ID=sc.doc.Objects.AddPolyline(pl)
print ID
findMyObj=sc.doc.Objects.Find(ID)
print findMyObj
So, first, I was able to create an invalid polyline definition (just two coincident points). Then in trying to add that invalid geometry to the document, it actually output an object ID - all 0’s… And of course, this ID isn’t valid and nothing was really added to the document…
Since I assumed that if an ID was produced, the AddPolyline function had succeeded, later on, when I tried to get that object back out of the document by finding its ID, the script failed…
So, the question is: if adding the object to the document fails - shouldn’t the function return None and not a bogus ID? Or is this considered to be normal behavior?
And, no, I’m not deliberately trying to add bad objects, it’s just that one method I am using - Polyline.ReduceSegments - actually does return invalid polyline definitions like above when the input polyline is very small…
Thanks,
–Mitch
