【发布时间】:2019-11-19 03:18:25
【问题描述】:
我正在尝试在 AutoCAD 中非常容易地绘制接线图,除了我的预编程按钮之外,几乎没有任何按钮按下。
其中一个涉及 LISP,它不能很好地设置系统变量,然后将它们重置为以前的状态。该程序似乎执行了预期的功能,但没有达到预期的结果。
一旦我的PLINE 命令启动,变量就会被重置。我需要PLINE 来启动、完成,然后然后重置变量。
我尝试在 LISP 的命令中以及通过 (setvar (getvar ...)) 命令设置 OrthoMode 和 SnapMode。
(defun varget ()
(setq lis '("orthomode" "snapmode"))
(setq var (mapcar 'getvar lis))
(setq var1 '(1 1))
(setq no 0)
(repeat (length lis)
(setvar (nth no lis) (nth no var1))
(setq no (1+ no))
)
(princ)
)
(defun varset ()
(setq no 0)
(repeat (length lis)
(setvar (nth no lis) (nth no var))
(setq no (1+ no))
)
(princ)
)
(princ)
(defun C:wire ()
(progn
(varget)
(setq prevlayer (getvar "clayer"))
(setq P (getstring "Audio(A)/Video(V)/Comm(CO)/Coax(R)/Control(C)/(N)etwork/(P)ower:"))
(IF (= P "V")(command "-LAYER" "M" "VIDEO" "C" "150" "" "" "PLINE" PAUSE))
(IF (= P "A")(command "-LAYER" "M" "AUDIO" "C" "94" "" "" "PLINE" PAUSE))
(IF (= P "CO")(command "-LAYER" "M" "COMM" "C" "206" "" "" "PLINE" PAUSE))
(IF (= P "R")(command "-LAYER" "M" "COAX" "C" "44" "" "" "PLINE" PAUSE))
(IF (= P "C")(command "-LAYER" "M" "CONTROL" "C" "10" "" "" "PLINE" PAUSE))
(IF (= P "N")(command "-LAYER" "M" "NETWORK" "C" "210" "" "" "PLINE" PAUSE))
(IF (= P "P")(command "-LAYER" "M" "POWER" "C" "7" "" "" "PLINE" PAUSE))
(setvar "clayer" prevlayer)
(varset)
(princ)
);Progn
);defun
没有错误消息。
我希望在执行PLINE 命令之后重置变量。
【问题讨论】:
标签: lisp autocad autocad-plugin autolisp