- 积分
- 53997
- 明经币
- 个
- 注册时间
- 2006-5-28
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2014-12-19 08:02:32
|
显示全部楼层
(defun c:tt-1 () ;(/ 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"))
(setq ss (ssget '((0 . "INSERT")))) ;选择对像,修改这里.
;(foreach name r
;(foreach (sslength ss) r
;(setq ss (ssget '((0 . "INSERT"))));选择对像,修改这里.
(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 (reverse atts) ;;;同一列前后颠倒
(foreach att atts
(princ (vla-get-TextString att) f)
(princ "," f)
)
(princ "\n" f) ;写出属性值
)
(close f)
)
)
)
;(close f)
)
)
;;;可以用了,但是排序有问题,EXCEL资料与图面属性块上下颠倒,还需要修正? |
|