Lisp(?) to draw Polyline across multiple center points

Lisp(?) to draw Polyline across multiple center points

Anonymous
Not applicable
15,025 Views
42 Replies
Message 1 of 43

Lisp(?) to draw Polyline across multiple center points

Anonymous
Not applicable

(Posting here, since when I posted on general foruns I was recommended to do so:)

Hi, people.
I need some help.

I'm stucked with a job that I must deliver done by next monday.
This job consist in redrawing routes based on older files to a new map and filling this routes with relevant information (I will expand on this later).
These routes are represented by polylines that must have its vertexes matching center points of a block.

 Capturar_1_sample.PNG

 

 

These blocks represent electrical poles (is that how we call it in english? I'm brazilian). I have been doing this clicking in center-point by center-point, one by one. And I'm fast.
But now I have a little health issue that's making me slower and slower. I have something that may translate to carpal tunnel syndrome in english and it's making my hand hurt really bad.

 

These routes, polylines, may demand thousands and thousands of clicks in the center points of these blocks, and if add the clicking for pan and navigation... I know it is quite normal in autocad, but when we are talking about this AND speed AND health issues... Things get dark.

 

The general view of the position of the poles it this:Capturar_1_generalview.PNG

 

 

 I believe it is possible to understand the size of this demon (and it hasn't even finished - pole-wise) with this image.

It is also possible to see here that I already have much of it done. But I do not.

These lines represent other things. In order to add and analyze the data I have to, I must redraw. I do not have enough time nor my english is flexible enough to explain it, but I have to see file by file and redraw it with my own two eyes and my own two hands. It is a insane-importantness-level thing, that may strenghen our argument in legal subjects in the next monday meeting.

 

So let's get to what I need help with.
I can write something in autoLISP, but I'm not good (nor I have the time to experiment) enough.

 

I want something that allow me to select these blocks - or circles - that I need and automatically draw a polyline based on it's center points. As the sample above showed.

I'm attaching this file so anyone who can help me may play with it.

The rules would be: one direction.
From the "first" center point" to the nearest next and so on until it "links" all the selected blocks/circles with this polyline.

 

Is it possible? Is there already a command or lisp out there that makes this for me? (didn't have luck so far with my search)

 

Capturar_1_sample_to_do.PNG 

Please, guys. Help me.

0 Likes
Accepted solutions (2)
15,026 Views
42 Replies
Replies (42)
Message 41 of 43

Sea-Haven
Mentor
Mentor

yes need a dwg but don't need line order if you drag a line over the lines near an end you can sort the points via distance away from 1st point. Do though need, is intersection point near start or end point ?

 

Try this limited testing.

SeaHaven_0-1670993760367.png

; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-draw-polyline-across-multiple-center-points/td-p/8038549/page/2

(defun LWPoly (lstpl cls)
 (entmakex (append (list (cons 0 "LWPOLYLINE")
                         (cons 100 "AcDbEntity")
                         (cons 100 "AcDbPolyline")
                         (cons 90 (length lstpl))
                         (cons 70 cls))
                   (mapcar (function (lambda (p) (cons 10 p))) lstpl))))
				   
(defun c:test ( / ss inspt stpt lst lst2 oldsnap )
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq stpt (getpoint "\nPick start point outside near end "))
(setq end (getpoint stpt "\nPick end point outside near end "))
(setq ss (ssget "F" (list stpt end) '((0 . "*LINE"))))
(command "line" stpt end "")
(setq obj (vlax-ename->vla-object  (entlast)))
(setq lst '() lst2 '())
(repeat (setq x (sslength ss))
  (setq ent (ssname ss (setq x (1- x))))
  (setq obj2 (vlax-ename->vla-object ent))
  (setq intpt (vlax-invoke obj2 'intersectWith obj acExtendThisEntity))
  (setq start (vlax-curve-getstartPoint obj2))
  (setq end (vlax-curve-getEndPoint obj2))
  (setq d1 (distance intpt end))
  (setq d2 (distance intpt start))
  (if (> d1 d2)
	(progn 
		(setq temp start)
		(setq start end)
		(setq end temp)
	)
  )
  (setq lst (cons start lst))
  (setq lst2 (cons end lst2))
)

(setq lst (vl-sort lst '(lambda (x y) (< (car x)(car y)))))
(setq lst2 (vl-sort lst2 '(lambda (x y) (< (car x)(car y)))))

(lwpoly lst 0)
(lwpoly lst2 0)

(vla-delete obj)

(setvar 'osmode oldsnap)
(princ)
)
(c:test)

 

 

0 Likes
Message 42 of 43

borislav_k_atanasov
Observer
Observer

Hi guys,

I'm after a similar task as the thread and I tried the lisp from DannyNL. The issues that I'm facing is that my circles are arranged in 3d environment and the  results that I get for the line gets a bit off:

result - off.jpg

I'm looking into connecting the centers of the circle on the X axis and if there is no circle within let's say 1000mm - to look for the nearest on the Y axis (I can completely ignore the Z axis).

I'm attaching a picture showing the desired result and I would be super grateful if anyone can assist:

target result.jpg

 

 

  

0 Likes
Message 43 of 43

martyn_jones9DSJ6
Observer
Observer
Amazing!
0 Likes