Here's a more consolidated way of doing it. Instead of explicitly putting into each new end Line's data the necessary parts of the data from the Line it's drawn across an end of, and to eliminate the need to check whether it has any overrides of color, linetype, etc., so the new Lines will include those, you can just keep all of that in making the new end Lines, and simply give them new endpoints. And you can spell out the across-the-end Line definition once, and apply it at both ends of each existing Line. Lightly tested:
(defun C:EndLines (/ liness ldata ang)
(prompt "\nTo draw 500-unit Lines across ends of existing Lines,")
(if (setq liness (ssget '((0 . "LINE"))))
(repeat (setq n (sslength liness))
(setq
ldata (entget (ssname liness (setq n (1- n))))
ang (angle (cdr (assoc 10 ldata)) (cdr (assoc 11 ldata)))
); setq
(foreach dxf '(10 11)
(entmake
(append
(vl-remove-if '(lambda (x) (member (car x) '(10 11))) ldata)
; everything except endpoints, including any optional overrides
(list ; new endpoints
(cons 10 (polar (cdr (assoc dxf ldata)) (+ ang (/ pi 2)) 250))
(cons 11 (polar (cdr (assoc dxf ldata)) (- ang (/ pi 2)) 250))
); list
); append
); entmake
); foreach
); repeat
); if
(princ)
); defun
It can also be done with even less code, by drawing one end Line, matching its properties to the existing one, and Copying it to the other end [all of those lumped together into one (command) function], but it's slower than the (entmake) approach:
(defun C:EndLines (/ liness line ldata ang p1 p2)
(prompt "\nTo draw 500-unit Lines across ends of existing Lines,")
(if (setq liness (ssget '((0 . "LINE"))))
(repeat (setq n (sslength liness))
(setq
line (ssname liness (setq n (1- n)))
ldata (entget line)
ang (angle (setq p1 (cdr (assoc 10 ldata))) (setq p2 (cdr (assoc 11 ldata))))
); setq
(command
"_.line"
"_none" (polar p1 (+ ang (/ pi 2)) 250)
"_none" (polar p1 (- ang (/ pi 2)) 250)
""
"_.matchprop" line (entlast) ""
"_.copy" (entlast) "" "_none" p1 "_none" p2
); command
); repeat
); if
(princ)
); defun
[By the way, in CADaStroumph's routine and either of mine, if the existing Lines might ever not lie in or parallel to the current construction plane, adjustments would be needed, because (polar) returns values in the current UCS.]
Kent Cooper, AIA