本帖最后由 作者 于 2006-12-7 16:50:38 编辑
(defun c:huitu1() (setq cm (getvar "cmdecho")) (setvar "cmdecho" 0) (command "_.UNDO" "Group") (setq p (list 0 0)) (setq ename (entnext (car (entsel "请选择要绘制的零件图所在的明细栏行:")))) (repeat 2 (setq elist (entget ename)) (if (= (cdr (assoc 0 elist)) "ATTRIB") (setq a (cdr (assoc 1 elist))) ) (setq ename (EntNext ename)) ) (setq f1 (strcat a ".txt")) ;获得工程数据库文件 (setq f1 (findfile f1)) (setq f (open f1 "r")) (setq a (read-line f ))
(command "script" "new.scr") ;此句在程序中没有得到执行
(command "insert" a p 1 1 0) (setq s (ssget "x")) ;选择插入的样本图后分解 (command "explode" s "") (setq a (read-line f )) (setq bk a) (setq a (strcat "("a")")) (setq a (read a)) (setq b (nth 0 a)) (setq a (read-line f )) (setq a (strcat "("a")")) (setq a (read a)) (setq m1 (nth 0 a)) (setq m2 (nth 1 a)) (setq m3 (nth 2 a)) (setq m4 (nth 3 a)) (setq m5 (nth 4 a)) (command "insert" bk p "" "" "" m1 m2 m3 m4 m5) ;插入带属性的图框 (cond ((= b "a0") (setq p (list 999 55))) ;当需要插入不同的图框时,把P点置为不同的坐标值 ((= b "a1") (setq p (list 651 55))) ((= b "a2") (setq p (list 404 55))) ((= b "a3") (setq p (list 235 50))) ((= b "a4") (setq p (list 25 50))) (t nil)) (setq a (read-line f )) (setq a (strcat "("a")")) (setq a (read a)) (setq len (length a)) (setq n1 1) (repeat len (setq char-B (nth (- n1 1) a)) ;获得要替换的文字 (setq char-A (strcat "VS" (itoa n1))) (reptext char-A char-B) ;替换尺寸文本 (prin1 char-A) (prin1 char-B) (setq n1(1+ n1)) ) (setq a (read-line f )) (setq a (strcat "("a")")) (setq a (read a)) (setq b (nth 0 a)) (while (= b "1") ;设置的判别符号,符号为1绘制明细表,否则不绘制明细表 (setq bk "mxb") ;插入明细表表头 (setq p1 (list (car p) (+ (cadr p) 10))) (command "insert" bk p 1 1 0) (while (setq a (read-line f )) ;循环插入明细表表栏,并填写相关内容 (setq a (strcat "("a")")) (setq a (read a)) (mxb a) (setq p1 (list (car p1) (+ 8 (cadr p1)))) ) ) (command "zoom" "a") ;把图形放至最大化 (command "script" "save.scr") (command "script" "close.scr") (command "_.UNDO" "End") (setvar "cmdecho" cm) (close f) ;关闭数据库文件 (princ) )
这是一段根据当前总装配图绘制零件图的程序,想把零件图绘制到新建的图纸上,所以中间我尝试着加了一行执行脚本的命令,但这样做,脚本没有被执行,新绘制的零件图和总装图绘在了同一个视口上。请大家帮我看看。脚本如下:
new ...........
脚本单独执行时是正确的
|