Jump to content

Intelligent joining, of lines


M76

Recommended Posts

I need to join lines together into one polyline.

 

The problem is that sometimes if there is a T junction, it will join the branch line to either part of the main line.

 

What do I need it to do to join the lines that are close to each other in angle, and keep the other ones seperate. ?

 

Is there an option besides manual supervision of each joint?

Link to comment
Share on other sites

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

  • M76

    17

  • ReMark

    6

  • fart_plume

    5

  • Tiger

    3

Top Posters In This Topic

Posted Images

What do you mean? Fillet trims or extends two selected lines together, how could I use it for this purpose?

 

The lines are already connected, I need to join the right ones into one polyline.

Link to comment
Share on other sites

I'm wondering how you join the lines? Do you have an automation of some kind, a lisp or a macro? My way of doing this would be manual labour, and then I select the right lines from the start - but it sounds like you do it some other way?

Link to comment
Share on other sites

There are a couple hundred files, and each with thousands of lines, manual labour is out of the question. Especially because this routine has to be completed on a file each time its changed.

 

If there is no other way I'll have to compare the angle of each line ending in a lisp, and determine which ones to join.

 

This is only a small part of a bigger project. I need to create buffer zones around the lines, and if the lines don't connect correctly the buffer won't look right at these junctions.

Link to comment
Share on other sites

Here is an example what will happen if the lines are joined incorrectly, and how it should look when the lines are connected the right way.

bad.jpg

good.jpg

Link to comment
Share on other sites

Can you leave a gap where the branch line joins, of half the width of your polyline. Then the gap would not show and the branch line would not join.

Link to comment
Share on other sites

The files are given. Creating a gap is only replacing the problem with another one that isn't any easier to implement.

Link to comment
Share on other sites

If there are hundreds of files and thousands of lines - will it make a difference how the joining is done, really? I bet you that everyone here is a stickler for it being exact - even when it really doesn't matter (89.5degrees is NOT 90 - but it's enough most of the times). Would the work you have to put into writing a lisp that determines what lines to join be worth it in the end?

Link to comment
Share on other sites

If there are hundreds of files and thousands of lines - will it make a difference how the joining is done, really?

Being a wiseguy about it won't help in making your point.

 

Of course it makes a difference, if there were only a few lines the logical solution would be to do it manually.

 

Would the work you have to put into writing a lisp that determines what lines to join be worth it in the end?

Its not the point, the reason I opened the topic is to find out, if there is any other solution. It needs to be done the question is only about the how.

 

Writing this algorithm isn't something that can be done in five minutes, so if possible I'd have liked to avoid it.

Link to comment
Share on other sites

Anyway since there were no real ideas, I've started to create the routine.

 

In the light of some of your responses, it would be a brave person who would suggest any more ideas.

 

As you say, better to go for the routine. Best of luck. :D

Link to comment
Share on other sites

Being a wiseguy about it won't help in making your point.

 

Of course it makes a difference, if there were only a few lines the logical solution would be to do it manually.

 

 

Its not the point, the reason I opened the topic is to find out, if there is any other solution. It needs to be done the question is only about the how.

 

Writing this algorithm isn't something that can be done in five minutes, so if possible I'd have liked to avoid it.

 

Hundreds of files and thousands of lines was your words, not mine. I apologise if my remark came off as 'wise guy'-ish - that was not my intent. I have stared myself blind at small faults myself just to after an hour or two realise that it will not make the slightest different in the end - since the answers you have gotten point towards that there is no easy solution, my question was to perhaps make you see if it was the same case with you now.

 

Since you say that it does indeed make a difference, I wish you good luck in making the algorithm - that kind of programming is far above my head so I bow out here.

Link to comment
Share on other sites

Hundreds of files and thousands of lines and how many intersections and endpoints will you have to analyse and then join? And how will you verify that it has been done correctly or to your satisfaction? What if the junction is made to the wrong branch? Sounds like you need a program with some artificial intelligence incorporated within it.

Link to comment
Share on other sites

Hundreds of files and thousands of lines and how many intersections and endpoints will you have to analyse and then join? And how will you verify that it has been done correctly or to your satisfaction? What if the junction is made to the wrong branch? Sounds like you need a program with some artificial intelligence incorporated within it.

 

The important thing is to join the lines that have a smaller difference in angles. That can be determined by comparing the last/first segment of the three connecting lines, there is no intelligence required for that.

 

I've finished the routine and it works, if anything that should be proof enough that it can be done. Its brute force, and its ugly, and probably can be done much more efficiently, so I won't bother posting it. Also its map3d specific.

Link to comment
Share on other sites

Well thank you for sharing the fact that it can be done. I'm disappointed you won't share your solution with the CAD community here at CADTutor. Now if someone here had come up with a solution you would have expected them to share it with you right? Right. Yeah, I thought so.

Link to comment
Share on other sites

I would have posted it if I thought anyone would benefit from it. But since, you asked so nicely :roll:

 

The map_clean and make-vert-list functions are not written by me, but since its useless without them I included those too.

 

But a word of warning, its not tested thoroughly, and the running time exponentially increases with the number of lines. It takes 3-5 minutes with 200 polylines. I didn't test it with anything more than that, but I assume the time could go up to hours with enough plines.

join.lsp

Link to comment
Share on other sites

M76: Thank you for posting the lisp routine. I'm sure someone else may derive some benefit from it as well.

 

3-5 minutes for 200 polylines? I can only imagine what it might take for thousands of polylines then. Aren't you afraid you'll lock up your system? What do you do while it is working away at the problem in the meantime? I hope you have a dedicated machine that can concentrate on those hundreds of files you mentioned.

 

Brute force you say? I say as long as it works who cares how ugly it is right?

 

Thanks again. :)

Link to comment
Share on other sites

M76: Thank you for posting the lisp routine. I'm sure someone else may derive some benefit from it as well.

 

3-5 minutes for 200 polylines? I can only imagine what it might take for thousands of polylines then. Aren't you afraid you'll lock up your system? What do you do while it is working away at the problem in the meantime? I hope you have a dedicated machine that can concentrate on those hundreds of files you mentioned.

 

Autocad locks up more times than I could count anyways. I'm not concerned with speed since its not even working correctly yet I mean the whole thing, not the joining. Joining the lines takes very little time compared to what autocad spends with unioning 2-3000 regions. That is if it not fails with an edge inconsistency error, which I'm yet to find a way around.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...