Has anyone else noticed inconsistencies between how rhino performs geometry operations when scripted vs. when used manually? For example, I’ve been using Offset() a lot during scripting for a CAM script. In order to get the output I want, i have converted closed curves to polylines, OK fine. I then want to offset inward to compensate for tool width, and i want the result to be a polyline as well, so i can easily extract points for the machine code. When i script this offset operation, however, i get another NURBS curve out, and this curve may or may not even be closed still. In contrast, when i offset the same curve myself in the graphics window I get the nice, closed polyline i desire. And these are not overly complicated shapes, either; think “lima bean”-like, fairly smooth. Is Rhino doing something different under the hood in each case? It would be nice to be able to trust my scripts to do everything the same as it works in the viewport.
Any insight would be much appreciated, as I’d rather not have to sample the curve myself, i feel it would be much more resource intensive for a file with a few thousand such objects
EDIT: I also noticed that when the scripted Offset() command does produce a polyline, Rhino will tell me that the offset polyline is open, even though the start and end points have identical coordinates in the details view. Could the implementation of Offset() be forgetting to alter the open/closed attribute of the object properly?
EDIT2: Actually, manually doing the offset in this case produces the same result, an open polyline with (closed) coordinates. Does Rhino have more trouble offsetting polylines with small segments?
Although the names of Rhino commands and scripting methods might be similar, the functionality between the two is often different. This is because there is no one-to-one correspondence between scripting methods and commands. The names may be similar, but they often do not not share underlying code.
If you want identical functionality, then you might consider scripting the command instead of calling a script method. For example, if you were using RhinoScript, You would script the Offset command using the Command() method.
With this said, we do try to make the functionality as close to the same as possible, so as not to cause confusion (like this). If you have an example of where a scripting method is producing different results than a command (or what you think is a corresponding command), then please post your geometry, sample script, and full command line syntax to the Rhino command so we can repeat the difference you are seeing here.
Thanks for the insight Dale. I figured that the two might be implemented using slightly different pieces of code. I think what I’m more concerned about is that Rhino doesn’t seem to be handling geometry itself consistently. Check out the file I’m attaching; the bean shape in green is an example of interest. When I offset the shape (closed polyline) inward by 0.125 I end up with an “open” polyline with identical start and end points. Now CTRL+C the shape into an emtpy doc. When I do this and offset again, the new curve ends up closed; what I want. Could you possibly educate me a little on why Rhino’s operations on the same geometry might differ between documents?polyTEST.3dm (885.5 KB)
EDIT: Also try offsetting the red outer contour to the outside, it seems to have problems with that too