AutoCAD帮助手册

  • 格式:doc
  • 大小:134.36 KB
  • 文档页数:35
)
) ; if
)
;主程序开始
(setq olderr *error*
*error* txterr
oldcmd (getvar "cmdecho")
)
(setvar "cmdecho" 0) ;命令不回显
(setq nn 9) ;词组分类数
(init) ;初始化
(diag) ;驱动对话框
(if (and ok txt)
二、原理及方法
AutoCAD对话框结构包含有多种构件,如edit_box(编辑框)、list_box(列表框)、radio_button(多选一按钮)等,利用这些工具,可以开发出界面友好的实用程序。
左图就是用这种方法实现的。将常用词组分类,分别存于不同的文件中。根据多选一按钮中所驱动的分组号分别打开不同的文件,将文件内容读入并显示于列表框内,供设计人员使用。同时,设有一个编辑框,可将所点取的词组显示于编辑框中,便于用户对词组进行适当的修改,如删除或增加字符等。这种方法有一个优点,用户可十分方便地根据自己需要修改或添加词组内容。对话框文件及驱动程序分别见#CAL.DCL及#CAL.LSP。
(if oldcmd (setvar "cmdecho" oldcmd))
(princ)
)
;对话框显示及驱动程序
(defun diag ( / i)
(if (> (setq dcl_id (load_dialog "#txt")) 0);加载对话框文件
(progn
(if (new_dialog "filetext" dcl [JX*6]id);显示对话框
二、原理及方法
AutoCAD对话框结构包含有多种构件,如edit_box(编辑框)、list_box(列表框)、radio_button(多选一按钮)等,利用这些工具,可以开发出界面友好的实用程序。
(defun txterr(s)
(if (and (/= s "console break")
(/= s "Function cancelled")
(/= s "quit / exit abort")
)
(princ (strcat "\nError:" s))
)
(if olderr (setq *error* olderr));恢复原系统设置
(setq fname1 (strcat "$txt" (itoa i) ".dat")
i nn
)
)
(setq i (1+ i))
)
(if (setq fname (findfile fname1));查找文件是否存在
(progn
(setq old_nn (atoi (substr fname1 5)));记录索引号
key = "c3";
}
: radio_button {
label = "卫生器具";
key = "c4";
}
: radio_button {
label = "管材配件";
key = "c5";
}
: radio_button {
label = "器材仪表";
key = "c6";
}
: radio_button {
)
(initget (+ 2 4));下面的输入值要求大于0
(setq ht (getreal "\n请输入字高<500>:"))
(if (not ht) (setq ht 500))
(setq pt (getpoint "\n请点取文字起点:"))
(command "text" pt ht 0 txt)
(setq old_nn 1);记录索引号
)
;更换列表框内词组显示内容
(defun wr_txt ( / fname fname1 fp txt1 i)
(setq i 1)
(while (<= i nn);判别哪个词组项被点中
(if (= (get_tile (strcat "c" (itoa i))) "1")
)
)
(setq *error* olderr);恢复原设置
(setvar "cmdecho" oldcmd)
(princ)
)
// #txt.dcl
//供#txt.lsp调用
filetext : dialog { //对话框名称
label = "常用词组"; //对话框标识
: row {
: boxed_coபைடு நூலகம்umn {
摘要[HT5SS]本文提出了一种用对话框实现AutoCAD内常用术语自动标注的方法。用这种方法,可方便地将各种常用术语标注在图中,为CAD应用提供了方便。
一、引言
汉字的标注在CAD设计制图中是一个重要的部分,也是一个较为繁琐、困难的部分。目前,在AutoCAD内汉字的输入大多采用拼音方式,对拼音不熟悉的人来说汉字的输入就很困难。如果能将设计中常用的文字术语直观地显示出来供设计人员调用,将会极大地提高工作效率。本文就此进行研究,提出了一种用对话框(下图)将常用术语显示并供调用的方法,同时给出了源程序,供大家参考。该程序已应用于我院的实际生产中。
AutoCAD内常用术语的自动标注方法
摘要[HT5SS]本文提出了一种用对话框实现AutoCAD内常用术语自动标注的方法。用这种方法,可方便地将各种常用术语标注在图中,为CAD应用提供了方便。
一、引言
汉字的标注在CAD设计制图中是一个重要的部分,也是一个较为繁琐、困难的部分。目前,在AutoCAD内汉字的输入大多采用拼音方式,对拼音不熟悉的人来说汉字的输入就很困难。如果能将设计中常用的文字术语直观地显示出来供设计人员调用,将会极大地提高工作效率。本文就此进行研究,提出了一种用对话框(下图)将常用术语显示并供调用的方法,同时给出了源程序,供大家参考。该程序已应用于我院的实际生产中。
height = 15;
width = 26;
allow_accept = true; //可双击鼠标选取
}
}
spacer_1;
: edit_box {//编辑框
label = "所选词组:";
key = "sel_ok";
}
spacer_1;//增加间距
ok_cancel;
}
AutoCAD内常用术语的自动标注方法
)
)
;初始化程序,把第1个分组项中的词组读入表txt_tb中
(defun init( / fname fp txt1)
(setq fname (findfile "$txt1.dat"))
(if (not fname)
(progn (princ "\n文件$TXT1.DAT不存在!") (exit)) ;文件不存在,则退出
本程序在AutoCAD R12.0 FOR DOS及FOR WINDOWS版上均调试通过。
(defun c:#txt ( / oldcmd olderr ok txt_tb txt dcl_id sty fp nn ht pt txterr diag init wr_txt old_nn)
;定义错误处理子程序
label = "索引";
: radio_button {
label = "常用术语"; //多选一按钮
key = "c1";
value = "1"; //初始值为"1",表示选中
}
: radio_button {
label = "图纸名称";
key= "c2";
}
: radio_button {
label = "房间名称";
(setq fp (open fname "r"))
(setq txt_tb '())
(while (setq txt1 (read_line fp));依次读出各词组
(setq txt_tb (cons txt1 txt_tb))
)
(close fp)
(setq txt_tb (reverse txt_tb))
(progn start_list "what");将词组显示到列表框内
(mapcar 'add_list txt_tb
)
(end_list)
(setq i 1)
(repeat nn;点取词组分类项后的操作
(action_tile(strcat "c" (itoa i)) "(wr_txt)")
(setq i (1+ i))
)
(setq fp (open fname "r"))
(setq txt_tb '())
(while (setq txt1 (read_line fp))
(setq txt_tb (cons txt1 txt_tb))
)
(close fp)
(setq txt_tb (reverse txt_tb))
label = "常用设备";
key = "c7";