我组装了这个让你试试。根据需要进行调整。
- (defun c:1 (/ *error* bs layerName pt ra SUS SUS_LST TERR)
- (setq SUS_LST (list "clayer")
- SUS (mapcar 'getvar SUS_LST)
- TERR *error*
- *error* ETRAP)
- (MAIN)
- (princ))
- (princ "1.lsp loaded...")
- (princ "\nType 1 to start program.")
- ;
- ; Main code
- ;
- (defun MAIN ()
- (setq layername "generalplumbingstack")
- (if (not (tblsearch "layer" layername))
- (command "._-layer" "_m" layerName ""))
- (if (/= (setq pt (getpoint "\nInsertion pt: ")) nil)
- (progn
- (setq bs (getint "\nBlock scale: "))
- (setq ra (getint "\nRotation angle: "))
- (command "._-insert" "plumbingstack1-30" pt bs bs ra)
- )
- )
- (RUS)
- (princ))
- (princ)
- ;
- ; Restore User Settings
- ;
- (defun RUS ()
- (setq *error* TERR)
- (if SUS (mapcar 'setvar SUS_LST SUS))
- (princ "\n1.lsp has completed and will now restore your settings and exit.")
- (princ))
- (princ)
- ;
- ; Error Trap
- ;
- (defun ETRAP (EMSG)
- (command nil nil nil)
- (if (not (member EMSG '("console break" "Function cancelled")))
- (princ (strcat "\nError:" EMSG)))
- (if SUS (mapcar 'setvar SUS_LST SUS))
- (princ
- (strcat "\n1.lsp has encountered a user error!"
- "\nProgram will now restore your settings and exit."))
- (setq *error* TERR)
- (terpri)
- (princ))
- (princ)
我想指出的是,最好在命令调用上使用entmake解决方案 |