我没有实验的数据,我只改了一下代码 现在你只需要对子程序部分进行分析就好了。上面的那些都是判断函数,没有什么作用了~ (defun c:zdh_layer() (setvar "cmdecho" 0) (setq sssz (ssget "x" (list(cons 0 "text")(cons 8 "zdh")))) (setq n 0) (setq ns (sslength sssz)) (while (< n ns) (setq sz (entget (ssname sssz n))) (setq text (cdr (assoc 1 sz))) (setq tt (strcase (substr text 1 2))) (cond ((= tt "SP") (progn (setq text (vl-string-subst "SPA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_sp"))(command "-layer" "n" "zdh_sp" "c" "1" "" "")) (setq lay "zdh_sp") (entext text lay) )) ((= tt "GD") (progn (setq text (vl-string-subst "GDA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_gd"))(command "-layer" "n" "zdh_gd" "c" "2" "" "")) (setq lay "zdh_gd") (entext text lay) )) ((= tt "DX") (progn (setq text (vl-string-subst "DXA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_dx"))(command "-layer" "n" "zdh_dx" "c" "3" "" "")) (setq lay "zdh_dx") (entext text lay) )) ((= tt "TR") (progn (setq text (vl-string-subst "TRA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_tr"))(command "-layer" "n" "zdh_tr" "c" "4" "" "")) (setq lay "zdh_tr") (entext text lay) )) ((= tt "ZS") (progn (setq text (vl-string-subst "ZSA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_zs"))(command "-layer" "n" "zdh_zs" "c" "5" "" "")) (setq lay "zdh_zs") (entext text lay) )) ((= tt "LD") (progn (setq text (vl-string-subst "LDA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_ld"))(command "-layer" "n" "zdh_ld" "c" "6" "" "")) (setq lay "zdh_ld") (entext text lay) )) ((= tt "WS") (progn (setq text (vl-string-subst "WSA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_ws"))(command "-layer" "n" "zdh_ws" "c" "7" "" "")) (setq lay "zdh_ws") (entext text lay) )) ((= tt "YS") (progn (setq text (vl-string-subst "YSA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_ys"))(command "-layer" "n" "zdh_ys" "c" "8" "" "")) (setq lay "zdh_ys") (entext text lay) )) ((= tt "HS") (progn (setq text (vl-string-subst "HSA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_hs"))(command "-layer" "n" "zdh_hs" "c" "9" "" "")) (setq lay "zdh_hs") (entext text lay) )) ((= tt "RS") (progn (setq text (vl-string-subst "RSA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_rs"))(command "-layer" "n" "zdh_rs" "c" "10" "" "")) (setq lay "zdh_rs") (entext text lay) )) ((= tt "RZ") (progn (setq text (vl-string-subst "RZA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_rz"))(command "-layer" "n" "zdh_rz" "c" "11" "" "")) (setq lay "zdh_rz") (entext text lay) )) ((= tt "GT") (progn (setq text (vl-string-subst "GTA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_gt"))(command "-layer" "n" "zdh_gt" "c" "12" "" "")) (setq lay "zdh_gt") (entext text lay) )) ((= tt "MQ") (progn (setq text (vl-string-subst "MQA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_mq"))(command "-layer" "n" "zdh_mq" "c" "13" "" "")) (setq lay "zdh_mq") (entext text lay) )) ((= tt "SY") (progn (setq text (vl-string-subst "SYA420" (substr text 1 2) text)) (if (not (tblsearch "layer" "zdh_sy"))(command "-layer" "n" "zdh_sy" "c" "14" "" "")) (setq lay "zdh_sy") (entext text lay) )) ) (setq n (1+ n)) ) ) ;********以下是子程序,用来判断吧~ (defun entext(text lay) (setq sz1 (subst (cons 1 text) (assoc 1 sz)sz)) (setq sz2 (subst (cons 8 lay) (assoc 8 sz1)sz1)) (setq szn (entmod sz2)) (setq pt1 (list (- (cadr(assoc 10 szn)) 0.5) (+ (caddr(assoc 10 szn)) 0.75))) (setq pt (ssget pt1)) (setq ent_pt (entget(ssname pt 0))) (setq ent_pt (subst (cons 8 lay)(assoc 8 ent_pt) ent_pt)) (entmod ent_pt) )
|