Another way to set MODEMACRO values is to use AutoLISP.
You can save the code samples shown here as ASCII format text files and load them with the AutoLISP load function.
The following AutoLISP command defines a MODEMACRO string that provides similar information to that in the built-in status line. Because AutoLISP cannot continue strings from line to line, you use the AutoLISP strcat function to assemble the complete MODEMACRO string from shorter component strings.
(defun C:ACADMODE ( )
(setvar "modemacro"
(strcat
"Layer $(substr,$(getvar,clayer),1,8)"
"$(if,$(getvar,orthomode), Ortho)"
"$(if,$(getvar,snapmode), Snap)"
"$(if,$(getvar,tabmode), Tablet)"
"$(if,$(=,$(getvar,tilemode),0),"
"$(if,$(=,$(getvar,cvport),1), P)"
")"
)
)
)
Save this AutoLISP routine in a file called acadmode.lsp. When you load the routine and execute it, it displays information on the status line. This is not the most useful application of this feature; it is provided only as an example.
The following sample acad.lsp file uses the S::STARTUP function to set the MODEMACRO variable to a string defined by the AutoLISP file mode1.lsp.
;;; Sample acad.lsp file that uses S::STARTUP to load the
;;; file MODE1.LSP which defines a MODEMACRO string
(defun S::STARTUP ( )
(load "mode1")
(princ)
)
;;; Additional AutoLISP files can also be defined or
;;; loaded here
When the AutoLISP file (mode1.lsp) is loaded, it uses the MODEMACRO system variable to define a status line that displays L: followed by the first eight characters of the layer name, the drawing name and a portion of the path, and the first letter of each name of the currently active modes. The position of the drawing name remains constant, regardless of the length of the layer name.
;;; MODE1.LSP
;;;
(setvar "modemacro"
(strcat
"L:$(substr,$(getvar,clayer),1,30)"
"$(substr, ,1,$(-,30,$(strlen,$(getvar,clayer)))) "
;; ^^^^^^^^ Note the 8 spaces here
"<.."
"$(if,$(eq,$(getvar,dwgname),UNNAMED),UNNAMED,"
"$(substr,$(getvar,dwgname),"
"$(if,$(>,$(strlen,$(getvar,dwgprefix)),29),"
"$(-,$(strlen,$(getvar,dwgprefix)),29),1"
"),"
"$(strlen,$(getvar,dwgname))"
")"
")"
">"
"$(if,$(getvar,orthomode), O, )"
"$(if,$(getvar,snapmode), S, )"
"$(if,$(getvar,tabmode), T, )"
"$(if,$(and,"
"$(=,$(getvar,tilemode),0),$(=,$(getvar,cvport),1)),P)"
)
)
Indenting code improves the readability of AutoLISP files and DIESEL strings.