trefan123 发表于 2022-7-5 15:58:54

Saveas命令

大家好,
在lisp例程中,如果用户使用savas命令,是否有方法重新加载lisp例程
谢谢

Aftertouch 发表于 2022-7-5 16:19:14

取消定义SAVEAS命令。
 
重新定义一个新的SAVE ass命令,该命令调用:。另存为,然后添加额外的行以加载lisp文件
 

(defun UNDEFINESAVEAS ( / )
(setvar "cmdecho" 0)
(command ".undefine" "SAVEAS")
(setvar "cmdecho" 1)
(princ)
)

(defun C:SAVEAS ( / )
(setvar "cmdecho" 0)
(load "YOURFILE.LSP")
(command ".SAVEAS")
(setvar "cmdecho" 1)
(princ)
)

(UNDEFINESAVEAS)
(princ)

trefan123 发表于 2022-7-5 16:46:48

你们这些家伙真厉害。
谢谢

ronjonp 发表于 2022-7-5 17:03:06

您也可以使用命令begin reactor。
 
快速示例:
;; COMMAND REACTORS
(or *startcommandreactor*
   (setq *startcommandreactor* (vlr-command-reactor nil '((:vlr-commandwillstart . strtcmd))))
)
;; List of commands to fire reactors (set layers textstyle etc...)
(setq *commands* "dim*,*table*,*xref,xattach,mview,*vports,*image*,*hatch,*leader,*text,saveas")
(defun strtcmd (calling-reactor strtcmdinfo / cs name)
(setq cs (strcase (car strtcmdinfo) t))
(if (wcmatch cs *commands*)
   (progn (cond ;; (replace the (print "*") with your code that does cool stuff
       ((wcmatch cs "saveas") (print "Saveas"))
       ((wcmatch cs "dim*") (print "Dimension"))
       ((wcmatch cs "*table*") (print "Table"))
       ((wcmatch cs "*xref,xattach") (print "Xref"))
       ((and (wcmatch cs "mview,*vports")) (print "Viewport"))
       ((wcmatch cs "*image*") (print "Image"))
       ((wcmatch cs "*hatch") (print "Hatch"))
       ((wcmatch cs "mleader") (print "Mleader"))
       ((wcmatch cs "*leader") (print "Leader"))
       ((wcmatch cs "*text") (print "Text"))
   )
   )
)
)
页: [1]
查看完整版本: Saveas命令