Jump to content
drdownload18

Connecting endpoints of vertical lines with polyline

Recommended Posts

drdownload18

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

Share this post


Link to post
Share on other sites
Lee Mac
Posted (edited)

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

Share this post


Link to post
Share on other sites
drdownload18

thank you very much, thats' what i needed :)

Share this post


Link to post
Share on other sites
BIGAL
Posted (edited)
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

Share this post


Link to post
Share on other sites
Lee Mac
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.

Share this post


Link to post
Share on other sites
BIGAL
Posted (edited)

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

Share this post


Link to post
Share on other sites
Lee Mac

No worries :)

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...