3d Ployline with huge amount of grips to 2d Polyline with much less grips

Hello everyone,

I hope this message finds you well and happy.

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?

dwg:
https://www.dropbox.com/scl/fo/4wkynuh40udjtbvwikcij/AP1EP3QnE-diSO1kgIds4CY?rlkey=miktw1wl9a7fyntbrp54ltbg5&st=o2bfdcz1&dl=0

Best regards,

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?

Hi,
Thank you. I want to retain the orginal shape (curve) not to a line

Is your entire 3D polyline on the XZ plane, or do you have different 3D polylines on different planes?

there are many polylines and each polyline is located in different plane. The orientation is variable for each polyline.

I am not sure a 2d polyline can be created in anything other than the XY plane. Can you make a 2D polyline with a Z value in the user interface?

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:

  1. Build a simple graph to bring the polylines into Dynamo’s geometry engine as PolyCurves.
  2. 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.
  3. 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.

A couple comments…

A polyline has an elevation value. No need for a UCS or anything like that.

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).

Thank you. Some how it works to reduce the vertices but its not enough. It probably better to make it manually.

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.