I’m working with a 3D polyline that has too many grips, and I need to simplify it. My goal is to convert this 3D polyline into 2D polyline, with a significantly fewer grips—ideally between 4 to 8 grips. I’ve tried several methods, but haven’t had much success.
Does anyone have any suggestions or know of any packages that could help achieve this?
Hi,
If you want a 2D polyline, it implies having a constant elevation. In your example, you have a 3D curve. If you want to obtain a 2D polyline, you only need two points.
Is that what you want?
Yes, it is possible. By setting the ZY plane as a new UCS, you can draw a 2D polyline within that coordinate system. I think it is possible to make a new Dynamo node for making a 2D polyline with a plane. I cound not find such nodes in Dynamo.
Ok. Dynamo doesn’t have the concept of a UCS, so you’re going to have to step into the AutoCAD API.
I would tackle this as follows:
Build a simple graph to bring the polylines into Dynamo’s geometry engine as PolyCurves.
Build a custom node to simplify your polylines; what simplify means varies by person to person, as an example you want to simplify a single arc, which seems silly to me as it won’t get simpler than it is. Exactly how you’d do this is not clear so you’ll have to work that logic out at a minimum.
Build a custom node that uses the AutoCAD API to convert the resulting polycurve into a 2D polyline.
What is your reason for wanting a 2D polyline instead of a 3d one? That last step is a LOT of work so you’ll have to evaluate the cost/benefit here.
That 3D polyline has 4,803 grips (points or vertices), which makes it challenging to create a solid. However, you can approximate this 3D polyline curve with a 2D polyline curve that has only 4 to 8 grips. Creating a solid from just 4 to 8 grips is much more efficient.
If you’re only doing this for a small number of polylines, it might be easiest to just use tools that Civil 3D already has. First one is the WEEDFEATURES command, which will work with a 3D polyline. You could use this as a first pass to cut down on the number of vertices. For fitting the line/curve segments, you could consider using the tools for creating a best-fit alignment, which contains a lot of the logic that you would be re-creating in Dynamo. Then just create a polyline from the resulting alignment.
If you want to continue with the Dynamo route, the Curve.ApproximateWithArcAndLineSegments may help, although there are no guarantees of tangency between segments (not sure if that is a requirement for you).
MAPClean can be very helpful for simplifying 3D Polylines or converting them to Polylines without losing the object structure. You can use Simplify Object option.