- 积分
- 2483
- 明经币
- 个
- 注册时间
- 2004-2-8
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2004-3-17 11:08:00
|
显示全部楼层
改好了,请试用。
比较一下二个程序的差别就知道其原理了,我稍微解释一下
if (null (tblsearch "LAYER" "CCD-SYB")) (command "_layer" "_m" "CCD-SYB" "_c" 4 "" "_lt" "continuous" "" "") ) 如果没有CCD-SYB这个图层,则创建一个,层名:CCD-SYB,颜色:4号,线型:实线
当然如果已有就不重复创建,这样,如果不希望颜色为4号的话可以不修改程序,只要重新定义这个CCD-SYB图层的定义。
(command "_.layer" "S" "CCD-SYB" "") 把CCD-SYB设置为当前层,明白其原理了吧,象这样的程序无非就是命令的批处理而已。
源程序如下:
; ---------------------------------------------------------
(defun ccd_err(s) (if (/= s "Function cancelled") (princ (strcat "\nError: " s)) ) (setvar "osmode" os) (setvar "CLAYER" clay) (setvar "TEXTSTYLE" ttp) (command "_.UNDO" "_E") )
;==================== Main program ========================
(defun c:ccd (/ os clay ttp pt1 sa sh scl pt2 pt3 pt4 pt5 ww ) (setq *error* ccd_err) (setq os (getvar "osmode") clay (getvar "CLAYER") ttp (getvar "TEXTSTYLE")) (if (null (tblsearch "LAYER" "CCD-SYB")) (command "_layer" "_m" "CCD-SYB" "_c" 4 "" "_lt" "continuous" "" "") ) (if (null (tblsearch "LAYER" "CCD-NOTE")) (command "_layer" "_m" "CCD-NOTE" "_c" 3 "" "") )
(command "_style" "romans" "romans.shx" "" "0.9" "" "" "" "") (setvar "osmode" 512) (setq pt1 (getpoint "\n放置位置: ") sa (getangle pt1 "\n角度(可以选择点决定角度):") scl (getvar "DIMSCALE") ) (if (= scl 0.0) (setq scl 1.0)) (setq pt2 (polar pt1 (+ (/ pi 3.0) sa) (* scl 7.5)) pt3 (polar pt1 (+ (/ pi 3.0) sa) (* scl 4.0)) pt4 (polar pt3 (+ pi sa) (* scl 4.0)) pt5 (polar pt1 (+ (/ pi 2.0) sa) (* scl 5.0))) (setvar "osmode" 0) (command "_.layer" "S" "CCD-SYB" "") (command "pline" pt2 "w" "0.0" "" pt1 pt4 pt3 "")
(if (and (> sa (* pi 0.5)) (< sa (* pi 1.5))) (setq sa (- sa pi))) (setq ww (getstring (strcat "\n粗糙度(1.6,3.2,6.3, 12.5,25) < 6.3 > : "))) (if (= "" ww) (setq ww "6.3")) (setq sa (* sa (/ 180 pi))) (command "_.layer" "S" "CCD-NOTE" "") (command "_.text" "_middle" pt5 (* scl 2.0) sa ww) (setvar "osmode" os) (setvar "CLAYER" clay) (setvar "TEXTSTYLE" ttp) (princ) ) ;============================================================== |
|