帮忙看看这个提取属性块的程序!
(defun c:tt (/ d r ss n obj atts)(while (setq d (tblnext "block" (null d)))
(setq r (cons (cdr (assoc 2 d)) r))
)
(and r
(setq filename (getfiled "属性输出文件名" "" "csv" 1))
)
(if filename
(progn
(setq f (open filename "w"))
(foreach name r
(setq ss (ssget "X" '((0 . "INSERT"))));选择对象,修改这里.
;(ssget ss(SSGET "X" '((0 . "INSERT") (8 . "目录")(66 . 1)) ));怎么全选目录这个属性块
(if ss
(progn
(setq atts (append
(vlax-invoke (setq obj (vlax-ename->vla-object (ssname ss 0))) 'GetConstantAttributes)
(vlax-invoke obj 'GetAttributes)
)
)
(princ "序号," f)
(foreach att atts
(princ (vla-get-TagString att) f)
(princ "," f)
);求出属性列表,写表头
(princ "\n" f)
(setq n -1)
(repeat (sslength ss)
(setq obj (vlax-ename->vla-object (ssname ss (setq n (1+ n)))))
(setq atts (append
(vlax-invoke obj 'GetConstantAttributes)
(vlax-invoke obj 'GetAttributes)
)
)
(princ (1+ n) f) (princ "," f)
(foreach att atts
(princ (vla-get-TextString att) f) (princ "," f)
)
(princ "\n" f);写出属性值
)
)
)
)
(close f)
)
)
)
有几个问题:
1:现在提取的数据会重复3次!
2:能否只提取 目录 这个属性块的值,我改了无法实现
3:能不能实现批量提取一个文件夹的数据!
看不出来... photo_cup 发表于 2014-10-23 17:36 static/image/common/back.gif
看不出来...
!!!!!!
页:
[1]