drdownload18 Posted April 9, 2019 Posted April 9, 2019 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 Quote
Lee Mac Posted April 9, 2019 Posted April 9, 2019 (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 April 9, 2019 by Lee Mac Quote
drdownload18 Posted April 9, 2019 Author Posted April 9, 2019 thank you very much, thats' what i needed Quote
BIGAL Posted April 10, 2019 Posted April 10, 2019 (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 April 10, 2019 by BIGAL Quote
Lee Mac Posted April 10, 2019 Posted April 10, 2019 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. Quote
BIGAL Posted April 11, 2019 Posted April 11, 2019 (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 April 11, 2019 by BIGAL Quote
hosyn Posted July 20, 2021 Posted July 20, 2021 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 ?? Quote
Lee Mac Posted July 20, 2021 Posted July 20, 2021 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? Quote
hosyn Posted July 21, 2021 Posted July 21, 2021 (edited) 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 : Edited July 21, 2021 by hosyn Quote
Recommended Posts
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.