- 积分
- 7582
- 明经币
- 个
- 注册时间
- 2006-7-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2014-3-12 16:59:04
|
显示全部楼层
谢谢,贴个类似的实现。
参考了猫的批量执行脚本
(defun c:newgetatti(/ qxpath qxname files data ff )
(setq ff (open "c:\\tempfiles\\bom.txt" "w"))
(princ "" ff)
(close ff)
(setvar "filedia" 0)
(setvar "sdi" 1)
(setvar "lispinit" 0)
(setq qxpath "C:\\tempfiles\\")
(setq qxname "*.dwg")
(setq files (vl-directory-files qxpath qxname 1))
;(setq files (FileNameSort files))
(setq data (car files))
(while data
(command "open" )
(command (strcat "c:\\tempfiles\\" data))
(getatti)
(command "qsave")
(setq files (cdr files))
(setq data (car files))
)
(setvar "sdi" 0)
(setvar "lispinit" 1)
(command "close")
)
(defun getatti(/ ss i ent elist tymc tydh js loop ename ff)
(setq ss (ssget "all" (list '(0 . "INSERT") (cons 2 "A4,A4横,A3,A2,A1,A0"))))
(if ss
(progn
(setq i (sslength ss))
(setq ent (ssname ss (setq i (1- i)))
ename (entnext ent)
loop t
)
(while (and ename loop)
(setq elist (entget ename))
(if (= (cdr (assoc 0 elist)) "ATTRIB")
(progn
(if (= (cdr (assoc 2 elist)) "图样名称")
(progn
(setq tymc (cdr (assoc 1 elist)))
)
)
(if (= (cdr (assoc 2 elist)) "图样代号")
(progn
(setq tydh (cdr (assoc 1 elist)))
)
)
(if (= (cdr (assoc 2 elist)) "件数")
(progn
(setq js (cdr (assoc 1 elist)))
)
)
)
(setq loop nil)
)
(setq ename (entnext ename))
)
)
)
(setq ff (open "c:\\tempfiles\\bom.txt" "a"))
(princ (strcat tymc "\t\t" tydh "\t" js "\n") ff)
(close ff)
(princ)
)
|
评分
-
查看全部评分
|