I can't find a good subject line for this post.
About my script.
The script takes the contents of a text file and pre-fills a quickleader's mtext contents.
The .txt files contain tags such as <FT> for foot, <L> for length, <W> for width, etc.
An example command to issue would be (smleader opt "name of .txt file")
I don't know how to use apostrophe's, mapcar, lambda. Those function are still difficult for me to understand.
There is a nested condition that I am still trying to figure out in the code. I bypassed the condition and try to pass arguments straight to main function which assembles my pre-formatted text.
Any help would be appreciated.
;Preformatted text
;
;
;Rectangle Example
;COMMAND: (smleader rrsw "rect")
;rect.txt file contents
;THIS IS A <L>' X <W>' RECTANGLE
;Length Example
;COMMAND (smleader len "length")
;length.txt file contents
;THIS IS A <FT>' LONG LINE
;Equipment Example
;COMMAND: (smleader equip "new-equipment")
;new-equipment.txt contents
;THE NEW EQUIPMENT IS <FT>', <OFFSET>
;STA. <STA>
(defun smleader (opt file)
(setq *file* file)
(setq *opt* opt)
;;opt options
(cond
((= opt equip)
(offsetfunc)
(station)
)
((= opt trench)
(lenghthfunc)
)
((= opt RRSW)
(RRSW)
)
)
(drawleader)
)
(defun drawleader (/ newstr offset ft sta fn ltext)
(setq newstr "")
(setq filename (strcat *file*".txt"))
(if (setq fn (open filename "r"))
(progn
(while (setq ltext (read-line fn))
(setq newstr (strcat newstr "\n" ltext))
)
(close fn)
(setq newstr (substr newstr 2 (strlen newstr)))
(princ newstr)
(setq newstr (vl-string-subst ft "<FT>" newstr 0))
(setq newstr (vl-string-subst offset "<OFFSET>" newstr 0))
(setq newstr (vl-string-subst (rtos sta 2 2) "<STA>" newstr 0))
(setq newstr (vl-string-subst L "<L>" newstr 0))
(setq newstr (vl-string-subst W "<W>" newstr 0))
)
)
(command "leader" pause pause "" "" "" newstr "")
(princ)
)
;;length function
(defun lengthfunc()
(setq ft (getint "\nWhat is the length"))
)
;;end
;;offset option
(defun offsetfunc ()
(initget "B\\CF F\\CF B\\EOP F\\EOP")
(setq offset (getkword "\nWhich curb offset [B\\CF/F\\CF/B\\EOP/F\\EOP]:")
)
(cond
((= offset "B\\CF")
(setq offset "B/CF")
)
((= offset "F\\CF")
(setq offset "F/CF")
)
((= offset "B\\EOP")
(setq offset "B/EOP")
)
((= offset "F\\EOP")
(setq offset "F/EOP")
)
)
(setq ft (itoa (getint "\nHow many feet offset:")))
(princ)
)
;;end offset option
;;station option
(defun station()
(setq sta (getreal "\nenter station number"))
(princ)
)
;;end station option
;;station option
(defun RRSW()
(setq L (rtos (getint "\nenter length")2 0))
(setq W (rtos (getint "\nenter width")2 0))
(princ)
)
;;end station option
error: bad argument type: (or stringp symbolp): nil