一个利用DCL设置CAD系统变量的例子,类似的利用这个可以设置其它系统变量。
DCL对话框代码如下。
dia5a:dialog {
label = "系统变量设置" ;
:edit_box {
edit_width = 6 ;
key = "edit_p" ;
label = "PlineWid" ;
}
:edit_box {
edit_width = 6 ;
key = "edit_f" ;
label = "FilletRad" ;
}
:edit_box {
edit_width = 6 ;
key = "edit_t" ;
label = "TextSize" ;
}
:edit_box {
edit_width = 6 ;
key = "edit_s" ;
label = "SaveTime" ;
}
ok_cancel;
}
LSP文件代码如下。
(defun c:dia5a ()
(setvar "cmdecho" 0)
(dcl_dia5a)
(prin1)
)
(defun dcl_dia5a ()
(setq dcl_id (load_dialog "dia5a"))
(new_dialog "dia5a" dcl_id)
(set_tile "edit_p" (rtos (getvar "plinewid")))
(set_tile "edit_f" (rtos (getvar "filletrad")))
(set_tile "edit_t" (rtos (getvar "textsize")))
(set_tile "edit_s" (rtos (getvar "savetime")))
(action_tile "accept" "(ok_dia5a) (done_dialog 1)")
(start_dialog)
)
(defun ok_dia5a ()
(setvar "plinewid" (atof (get_tile "edit_p")))
(setvar "filletrad" (atof (get_tile "edit_f")))
(setvar "textsize" (atof (get_tile "edit_t")))
(setvar "savetime" (atof (get_tile "edit_s")))
)
代码完。
先将DCL和LSP文件路径设置为AutoCAD自动搜索路径,才可以加载成功。