Mohamed_Essam_2000 Posted Thursday at 02:09 AM Posted Thursday at 02:09 AM 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 Friday at 11:51 AM Posted Friday at 11:51 AM (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 Friday at 12:15 PM Author Posted Friday at 12:15 PM 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 Friday at 12:21 PM Posted Friday at 12:21 PM (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 Friday at 12:27 PM Author Posted Friday at 12:27 PM (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 Friday at 12:36 PM by Mohamed_Essam_2000 Quote
fuccaro Posted Friday at 12:34 PM Posted Friday at 12:34 PM Yes, in the original request I missed that "towards the other end point". Quote
fuccaro Posted Friday at 12:39 PM Posted Friday at 12:39 PM 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 Friday at 12:43 PM Author Posted Friday at 12:43 PM 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 Friday at 10:30 PM Posted Friday at 10:30 PM (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 Friday at 10:31 PM by BIGAL 1 Quote
Mohamed_Essam_2000 Posted Saturday at 04:19 PM Author Posted Saturday at 04:19 PM 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.