@marko_ribar wrote:
Here, I revised my code and it works... Slooow, but it works...
Marko, I think repeated selection sets makes it slow.
Here is a demo, all the objects are processed from a single selection set. The lisp version takes 30 sec., the compiled version only 15 sec.
(anyway, the video is edited, for the entire area some of the waiting time is cut off)
The lisp is unfinished, so I'm not going to post it yet.
The algorithm is pretty simple, in each step retain the last segments and add them to all branches (from the previous step) for which there is a continuity, eliminate the shortest branches, eliminate all from the initial list, repeat...
Because every polyline direction is downstream, you only need to search if the start point of a polyline is the end point of any other remaining polylines. If not, it is an end segment.
There are some issues with this algorithm. If an object is duplicated, it is never found as the last segment and the lisp ends in an infinite loop.