Jump to content

Connecting endpoints of vertical lines with polyline


drdownload18

Recommended Posts

Can somebody help me create lisp wich will create POLYLINE by connecting endpoints of vertical lines? (1 polyline with vertex on each endpoint of selected lines) Tnx
 

lisss.jpg

Link to comment
Share on other sites

Quick one:

(defun c:test ( / i l s x )
    (if (setq s (ssget '((0 . "LINE"))))
        (progn
            (repeat (setq i (sslength s))
                (setq i (1- i)
                      x (entget (ssname s i))
                      l (cons (cons 10 (cdr (assoc (if (< (caddr (assoc 10 x)) (caddr (assoc 11 x))) 11 10) x))) l)
                )
            )
            (entmake
                (append
                    (list
                       '(000 . "LWPOLYLINE")
                       '(100 . "AcDbEntity")
                       '(100 . "AcDbPolyline")
                        (cons 90 (length l))
                       '(070 . 0)
                    )
                    (vl-sort l '(lambda ( a b ) (< (cadr a) (cadr b))))
                )
            )
        )
    )
    (princ)
)

Chooses line end point with greatest y-coordinate; assumes 2D & WCS.

Edited by Lee Mac
Link to comment
Share on other sites

Quote

Chooses line end point with greatest y-coordinate; assumes 2D & WCS.

Lee any reason to not use ssget "F" then  just get max y of each line in order.

 

Just drag over lines, it sort of just makes sense to me to use that type of selection method given task.

 


(defun c:test ( / i l s x pt1 pt2)
(setq pt1 (getpoint "pick 1st point before lines"))
(setq pt2 (getpoint pt1 "pick second point past lines"))
    (if (setq s (ssget "F" (list pt1 pt2) '((0 . "LINE"))))
        (progn
            (repeat (setq i (sslength s))
                (setq i (1- i)
                      x (entget (ssname s i))
                      l (cons (cons 10 (cdr (assoc (if (< (caddr (assoc 10 x)) (caddr (assoc 11 x))) 11 10) x))) l)
                )
            )
            (entmake
                (append
                    (list
                       '(000 . "LWPOLYLINE")
                       '(100 . "AcDbEntity")
                       '(100 . "AcDbPolyline")
                        (cons 90 (length l))
                       '(070 . 0)
                    )
                     l 
                )
            )
        )
    )
    (princ)
)

 

Nice entmake method, using length l

Edited by BIGAL
Link to comment
Share on other sites

6 hours ago, BIGAL said:

Lee any reason to not use ssget "F" then  just get max y of each line in order.

 

Just drag over lines, it sort of just makes sense to me to use that type of selection method given task.

 

With the original code the use may still use a Fence selection (by typing "F" at the prompt), but may also use any other standard selection method to achieve the same result; I saw no reason to force the user to use a Fence selection, which may not necessarily be suitable in all circumstances.

Link to comment
Share on other sites

Lee your right did not think about just pressing F so many people are not aware of the basic selection methods available. WP being another usefull.

 

I took it for granted this is for probbably drawing long sections or cross sections.

Edited by BIGAL
Link to comment
Share on other sites

  • 2 years later...
On 4/10/2019 at 2:39 AM, Lee Mac said:

Quick one:


(defun c:test ( / i l s x )
    (if (setq s (ssget '((0 . "LINE"))))
        (progn
            (repeat (setq i (sslength s))
                (setq i (1- i)
                      x (entget (ssname s i))
                      l (cons (cons 10 (cdr (assoc (if (< (caddr (assoc 10 x)) (caddr (assoc 11 x))) 11 10) x))) l)
                )
            )
            (entmake
                (append
                    (list
                       '(000 . "LWPOLYLINE")
                       '(100 . "AcDbEntity")
                       '(100 . "AcDbPolyline")
                        (cons 90 (length l))
                       '(070 . 0)
                    )
                    (vl-sort l '(lambda ( a b ) (< (cadr a) (cadr b))))
                )
            )
        )
    )
    (princ)
)

Chooses line end point with greatest y-coordinate; assumes 2D & WCS.

HI GUYS

How we can modified it for doing this for pline ??

Link to comment
Share on other sites

20 hours ago, hosyn said:

HI GUYS

How we can modified it for doing this for pline ??

 

Do you mean if the vertical lines are two-vertex 2D polylines?

Link to comment
Share on other sites

18 hours ago, Lee Mac said:

 

Do you mean if the vertical lines are two-vertex 2D polylines?

No, just i want modify it for connect two endpoint of any pline indeed following :

temp44.JPG

Edited by hosyn
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...