Hello,
I’m trying to draw closed polylines/3d-polylines and I’m somewhat confused.
When feeding coordinates (that do not have duplicate start-/endpoints - e.g. four coordinates to form a square as shown in the screenshot below) and the flag “connectLastToFirst” set to true, the nodes “Polyline.ByGeometry” or “Polyline3d.ByGeometry” will always result in geometry that has five points (duplicating the start- and endpoint) if I click through the points in Autocad:
If I use Dynamo to convert the polyline-points back to Dynamo geometry, I’m again at only four points. The fifth point only shows up for the actual geometry that is drawn in Autocad.
I’m not sure if this is a bug or if I’m missing something. In the end, I’d like to create geometry without duplicate points.
(This is just a guess - someone with a better understanding of C3D will have to confirm or correct my assumptions here.)
I would think this is simply the difference between an Autocad PolyLine object and a Dynamo PolyCurve object. It would seem that a PolyLine must be (or at least in this case, is) unclosed, meaning that 4 segments would be defined by 5 points. Whereas a PolyCurve can be closed or unclosed, allowing for 4 segments to be defined by 4 points (with an implicit connection back to the first point for closed loops). In this scenario, the 5th point isn’t redundant - it’s necessary to complete the 4th and final segment of the PolyLine.
1 Like
Thank you for your reply!
Unfortunately, that’s not the case, as far as I know. Polylines, 3d-polylines and featurelines do have a setting for "Closed/Unclosed”. If you draw a rectangle using the “_RECTANGLE”-command, it will be a polyline that is set to "closed” but only consists of four points:
Those “tiny mistakes” can result in errors down the line (at least I think they can - I’ve never done isolated tests): geometry that can’t be offset, surfaces that won’t accept those polylines as boundaries and so on.
But I’m not even sure if this fifth point is real as it is neither present as an input nor does it show up as an output in Dynamo
This is pretty much it.
There are two types of polylines - closed and unclosed - in AutoCAD.
The source code isn’t published so I can’t confirm, but I would hazard a guess that the Polyline.ByGeometry doesn’t bother to check if the PolyCurve is closed in Dynamo, but just extracts each curve and generates a segment therefrom, resulting in an open PolyLine which just so happens to have start and end points at the same location, but is actually open.
Edit
Here is the link to the AutoCAD API showing that PolyLine3D has a closed property, and you can navigate the API docs to find that the constructors all provide open polylines.
Alright, I hope that’s just it!
It’s interesting:
I have a lisp that checks for self intersections and it does say that the polyline I created in my first post does not intersect itself.
It does cry out for other polylines and those usually are the ones that cause problems. The polyline that was posted in this post was flagged by my lisp and it behaves just the same: a duplicate point at one node.