A Line Tree problem

A Line Tree problem

zph
Collaborator Collaborator
723 Views
2 Replies
Message 1 of 3

A Line Tree problem

zph
Collaborator
Collaborator

I have been thinking about a problem of a different sort and I thought I might throw this up and see how you guys might handle it.  Given the attached example drawing, I'd like to be able to acquire the entity names of each of the lines that are on the "0" layer (the white ones).  However, the manner in which this is accomplished has to be by proximity and/or touching of lines.

 

For example, I've identified the line that will be selected with a "1".  In order to accomplish my goal, when I select that line, I find the endpoints, use those to generate a slightly larger crossing (search) window to locate line "2".  I can then repeat this search using the endpoints of line "2" to find line "3" and so on.  I'll call this method CROSSING.

 

CROSSING seems to mimic the result of FASTSEL, but I am looking to be able to filter each subsequent selection set by the layer and then do FASTSEL again and again until all the "ends" are found and no more lines exist to be found that fit the search parameters.

 

My first thoughts are to try to avoid hard coding the CROSSING/FASTSEL function 10 times so I can collect all 10 line objects.  Also, even if they are hard coded 10 times, what if the drawing needs 11 and I am not able to acquire the last line?

 

I am not sure of the best way to handle this problem.

How would you handle the problem?  Do you know of any existing routines that handle this problem?

 

I look forward to your responses.  Thanks!

~Z

 

 

0 Likes
724 Views
2 Replies
Replies (2)
Message 2 of 3

john.uhden
Mentor
Mentor

I didn't look at your drawing, but if you don't have to necessarily pick a specific first line, then I would grab a selection set of all the lines on the specified layer and test if others in the selection set are "touching" the ends of the 1st, then 2nd, then 3rd, and so on...

Take the first line in the selection set and call its ends p1 and p2.

If you find another line that "touches" p1, then take its opposite end as the new p1.

If you find another end that "touches" p2, then take its opposite end as the new p2.

Each time you find one that touches, remove it from the selection set.

Ultimately the selection set will contain only those lines that continuously "touch", like a polyline.

OR (easier)...

PEDIT; Join all the lines in the layer to the first one picked.  It won't join ones that are not touching.  If you want them all back as lines, just explode the polyline (entlast)

John F. Uhden

0 Likes
Message 3 of 3

CodeDing
Advisor
Advisor

@zph

 

This has been fun looking into. Actually, looking at the Fastsel.lsp file, it can easily be modified (or copied/modified for that matter) to accommodate what you are asking for. But I don't know if that is legal or not. Perhaps someone more savvy than I (like @john.vellek) can follow up on that?

 

Best,

~DD

0 Likes