Convert individual lines to polyline

1
CSGemini
5/5/2022 5:07 PM

I am currently evaluation this product. Very impressed so far and on the verge of purchasing.

I currently have a dxf with individual lines that i need to convert to a polyline. I have looked at a solution of taking a line and finding any other lines in the entities with the same end or start point and then doing the same for the line found therefore been able to find connecting lines and from that create a polyline. This works but does an easier way exist within the product that would be better for me to use?

Thank you.

Chris

Wout
5/6/2022 9:51 AM

Hi Chris,

There's no ready made solution in CadLib for this.

In general how you do this efficiently is use a scan line algorithm. First you sort all points by increasing x, and then y, and then and sweep a vertical line from left to right. Then at every point you encounter, you connect line segments that are starting/ending at this point.

It's a tricky thing to do robustly, there are many cases of floating point inaccuracies, non-closed polylines, or cases where more than 2 line segments touch a single point.

- Wout

CSGemini
5/6/2022 12:53 PM

That makes sense. Our drawings are quite simplistic which negates the chance of some edge cases. non-closed polylines is actually what im looking for and it seems to work well as you describe. With a list of remaining line entities to be join if any are left then it is no a closed polyline.

Thank you.

1