;DLD.lsp - Draw a vertical line next to multiple lines of
;text during a leader command.
(defun C:DLD()
;turn system echo off
(setvar "cmdecho" 0)
;get the start point of the leader line
(setq pt1(getpoint "\n Start Point: "))
;setup some variables to be used later
;[tp1] is a temporary point
;[cntr] is a counter
;[tht] holds the current text size
(setq tpt pt1 cntr 0 tht (getvar "textsize"))
;unremark the next line and replace YOUR_LAYER_NAME with your layer name,
;this would be the layer name for your leader lines and arrow head.
;If you are using a version of autocad above 14 you might have to replace
;"layer" with "-layer" or perhaps "_layer". You could write a function
;to check the version of autocad and decide which to use at that point.
;(command "layer" "set" "YOUR_LAYER_NAME" "")
;loop until the user quits selecting points
(while (/= nil(setq tpt(getpoint tpt "\n Next Point: ")))
;if it is the first point the user has selected
(if(= cntr 0)
;start the leader command to get an arrow head and the first line
;then use the (command) function to exit the leader command
(command "dim1" "lea" pt1 tpt (command))
;else just draw lines
(command "line" oldpt tpt "")
)
;increment the counter
(setq cntr(+ cntr 1))
;get the angle of the last line drawn
(setq angl(angle oldpt tpt))
;save the last point drawn
(setq oldpt tpt)
)
;find the location for the text using the
;text size times 0.25
(setq txpt(polar oldpt angl (* tht 0.25)))
;loop while the user types in something besides
;the T allows spaces in the text string
(while(/= "" (setq str(getstring T "\n Text: ")))
;unremark the next line and replace YOUR_LAYER_NAME with your layer name.
;this would be the layer name for your text. If you are using a version
;of autocad above 14 you might have to replace "layer" with "-layer" or
;perhaps "_layer". You could write a function to check the version of
;autocad and decide which to use at that point.
;(command "layer" "set" "YOUR_LAYER_NAME" "")
;check the last line angle to decide whether the text
;should be Left or Right Justified.
(if(or(< angl (/ pi 0.5))(> angl (* pi 1.5)))
;left justified
(command "text" "j" "ML" txpt "" 0 str)
;right justified
(command "text" "j" "MR" txpt "" 0 str)
)
;unremark the next line and replace YOUR_LAYER_NAME with your layer name.
;this would be the layer name for the vertical line next to the text.
;If you are using a version of autocad above 14 you might have to replace
;"layer" with "-layer" or perhaps "_layer". You could write a function
;to check the version of autocad and decide which to use at that point.
;(command "layer" "set" "YOUR_LAYER_NAME" "")
;draw the vertical line
(command "line"
(polar oldpt (* pi 0.5) (/ tht 2.0))
(polar oldpt (* pi 1.5) (+ (/ tht 2.0)(* tht 0.25)))
""
)
;reset the text starting location down a line
(setq txpt (polar txpt (* pi 1.5) (+ tht(* tht 0.25))))
;reset the location of the next vertical line
(setq oldpt(polar oldpt (* pi 1.5) (+ tht(* tht 0.25))))
)
;reset the system echo
(setvar "cmdecho" 1)
;suppress the last echo
(princ)
)
;End of Program