Mohamed_Essam_2000 Posted November 21 Posted November 21 Need a lisp to draw a line (2mm length and yellow colored) from the end point of the selected line towards the other end point. Quote
fuccaro Posted November 22 Posted November 22 (defun c:pp() (setq line (entget (car (entsel "select line to be extended "))) dist 2.0 pa (cdr (assoc 10 line)) pb (cdr (assoc 11 line)) lay (assoc 8 line) len (distance pa pb) rl (/ dist len) pc (mapcar '(lambda(a b)(+ b (* rl (- b a)))) pa pb) pd (mapcar '(lambda(a b)(- a (* rl (- b a)))) pa pb) ) (entmake (list '(0 . "LINE")(cons 10 pb)(cons 11 pc)'(62 . 2) lay )) (entmake (list '(0 . "LINE")(cons 10 pa)(cons 11 pd)'(62 . 2) lay )) ) 1 Quote
Mohamed_Essam_2000 Posted November 22 Author Posted November 22 21 minutes ago, fuccaro said: (defun c:pp() (setq line (entget (car (entsel "select line to be extended "))) dist 2.0 pa (cdr (assoc 10 line)) pb (cdr (assoc 11 line)) lay (assoc 8 line) len (distance pa pb) rl (/ dist len) pc (mapcar '(lambda(a b)(+ b (* rl (- b a)))) pa pb) pd (mapcar '(lambda(a b)(- a (* rl (- b a)))) pa pb) ) (entmake (list '(0 . "LINE")(cons 10 pb)(cons 11 pc)'(62 . 2) lay )) (entmake (list '(0 . "LINE")(cons 10 pa)(cons 11 pd)'(62 . 2) lay )) ) Thank you, bro. but if I finally want to delete the original line (the white line). It will be better if the multi selection is enabled, so that we can select many lines and apply this lisp. Quote
fuccaro Posted November 22 Posted November 22 (defun c:pp() (setq oldLine (car (entsel "select line to be extended ")) line (entget oldLine) dist 2.0 pa (cdr (assoc 10 line)) pb (cdr (assoc 11 line)) lay (assoc 8 line) len (distance pa pb) rl (/ dist len) pc (mapcar '(lambda(a b)(+ b (* rl (- b a)))) pa pb) pd (mapcar '(lambda(a b)(- a (* rl (- b a)))) pa pb) ) (entmake (list '(0 . "LINE")(cons 10 pb)(cons 11 pc)'(62 . 2) lay )) (entmake (list '(0 . "LINE")(cons 10 pa)(cons 11 pd)'(62 . 2) lay )) (entdel oldLine) ) This will delete the original line. 1 Quote
Mohamed_Essam_2000 Posted November 22 Author Posted November 22 (edited) 12 minutes ago, fuccaro said: (defun c:pp() (setq oldLine (car (entsel "select line to be extended ")) line (entget oldLine) dist 2.0 pa (cdr (assoc 10 line)) pb (cdr (assoc 11 line)) lay (assoc 8 line) len (distance pa pb) rl (/ dist len) pc (mapcar '(lambda(a b)(+ b (* rl (- b a)))) pa pb) pd (mapcar '(lambda(a b)(- a (* rl (- b a)))) pa pb) ) (entmake (list '(0 . "LINE")(cons 10 pb)(cons 11 pc)'(62 . 2) lay )) (entmake (list '(0 . "LINE")(cons 10 pa)(cons 11 pd)'(62 . 2) lay )) (entdel oldLine) ) This will delete the original line. But the total length will not be extended. the total length is required to be constant. I mean, the yellow line will start from the end-point of the oldline towards the other end-point. Edited November 22 by Mohamed_Essam_2000 Quote
fuccaro Posted November 22 Posted November 22 Yes, in the original request I missed that "towards the other end point". Quote
fuccaro Posted November 22 Posted November 22 So... this can process more lines at a time. (defun c:pp() (setq dist 2.0 lines (ssget '((0 . "LINE"))) n (sslength lines)) (repeat n (setq l1 (ssname lines (setq n (1- n))) line (entget l1) pa (cdr (assoc 10 line)) pb (cdr (assoc 11 line)) lay (assoc 8 line) len (distance pa pb) rl (/ dist len) pc (mapcar '(lambda(a b)(+ b (* rl (- a b)))) pa pb) pd (mapcar '(lambda(a b)(- a (* rl (- a b)))) pa pb) ) (entmake (list '(0 . "LINE")(cons 10 pb)(cons 11 pc)'(62 . 2) lay )) (entmake (list '(0 . "LINE")(cons 10 pa)(cons 11 pd)'(62 . 2) lay )) (entdel l1) ) ) 1 Quote
Mohamed_Essam_2000 Posted November 22 Author Posted November 22 2 minutes ago, fuccaro said: So... this can process more lines at a time. (defun c:pp() (setq dist 2.0 lines (ssget '((0 . "LINE"))) n (sslength lines)) (repeat n (setq l1 (ssname lines (setq n (1- n))) line (entget l1) pa (cdr (assoc 10 line)) pb (cdr (assoc 11 line)) lay (assoc 8 line) len (distance pa pb) rl (/ dist len) pc (mapcar '(lambda(a b)(+ b (* rl (- a b)))) pa pb) pd (mapcar '(lambda(a b)(- a (* rl (- a b)))) pa pb) ) (entmake (list '(0 . "LINE")(cons 10 pb)(cons 11 pc)'(62 . 2) lay )) (entmake (list '(0 . "LINE")(cons 10 pa)(cons 11 pd)'(62 . 2) lay )) (entdel l1) ) ) Thank you very much, bro. 1 Quote
BIGAL Posted November 22 Posted November 22 (edited) @Mohamed_Essam_2000 just a comment in future for similar request it would be more helpful if you refer to the task as "from start point towards end point", this makes it clear which end to draw from, the reason I say this is often use select an end to determine the direction you want to draw in, this allows for swapping of line direction if needed. As shown by @fuccaro the start point for a line is dxf (cdr (assoc 10 line)) or VL (vlax-curve-getstartPoint obj) or (getpropertyvalue (car (entsel)) "startpoint") Edited November 22 by BIGAL 1 Quote
Mohamed_Essam_2000 Posted November 23 Author Posted November 23 17 hours ago, BIGAL said: @Mohamed_Essam_2000 just a comment in future for similar request it would be more helpful if you refer to the task as "from start point towards end point", this makes it clear which end to draw from, the reason I say this is often use select an end to determine the direction you want to draw in, this allows for swapping of line direction if needed. As shown by @fuccaro the start point for a line is dxf (cdr (assoc 10 line)) or VL (vlax-curve-getstartPoint obj) or (getpropertyvalue (car (entsel)) "startpoint") I agree with you. Ok, I will. 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.