Create lines between points

Create lines between points

Anonymous
Not applicable
17,425 Views
4 Replies
Message 1 of 5

Create lines between points

Anonymous
Not applicable

Hi,

 

I have imported about 2500 points positioned after each other (see image below) and I'd like to connect them with lines. Of course I could do it manually but I wonder if there is a function to connect adjacent points to each other automatically?

All I've found searching online is a function for AutoCAD Civil which I can't find in the "regular" AutoCAD 2017.

 

Does anyone have an idea of how to do this?

 

Thanks!

 

Ground Elevation Points.png

0 Likes
Accepted solutions (1)
17,426 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

By any chance, can you count on those Points always being drawn in sequence along that route?  If so, I think I can imagine a way to do it.  If not, it would be quite an undertaking, because it would require getting the distances from every Point to every other one, and determining the smallest distances to find the adjacencies.

 

EDIT:  If they're drawn in sequence, try this, selecting the Points all in one window  so that their sequence in the selection set is their drawn order:

 

(setq
ss (ssget '((0 . "POINT")))
n -1
) (command "_.line") (while (setq ent (ssname ss (setq n (1+ n)))) (command (cdr (assoc 10 (entget ent)))) ) (command "")

It's probably worth using "_.pline" instead of "_.line" -- a significant memory saver with that many Points.

 

That's in the very simplest terms -- it could use Osnap control, etc., etc.

Kent Cooper, AIA
Message 3 of 5

Anonymous
Not applicable

Originally these points were a polyline created from a pdf import. The problem with that polyline was that it was very complex and "heavy" to work with, so I divided it (with the divide command) into even segments and was hoping to be able to easily reconnect them. 

I assume the points are in order because I used the divide command? 

You also bring up an interesting question. In my search for solutions I stumbled upon the AutoCAD Civil solution of creating lines between point numbers (which is a function I can't find), but I haven't even been able to find the point numbers. Is there a way to show (if they exist) the point numbers?

 

The script you provided worked like a charm! Thanks a lot!

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Originally these points were a polyline created from a pdf import. The problem with that polyline was that it was very complex and "heavy" to work with, so I divided it (with the divide command) into even segments and was hoping to be able to easily reconnect them. 

....


If the complexity and heaviness is in having many more vertices than you need for your purposes, there are routines out there to reduce the vertex density.  One is PLDIET.lsp with its PLD command, available >>here<<.  You don't need to place Points with Divide -- it will just put the Polyline on a Diet.

 

If by "heavy" you actually mean it's a "heavy" 2D Polyline and not a LW Polyline, you can convert it with CONVERTPOLY, or there's WEED.lsp [at Post 1 on that thread] that was written to work with those.

Kent Cooper, AIA
0 Likes
Message 5 of 5

Anonymous
Not applicable

I'm pretty sure it's a lightweight polyline, just that it was very slow to work with and it took several seconds to select it. I'll make sure to check out the PLDiet as well. 

Thanks a lot for all your help!

0 Likes