- 积分
- 906
- 明经币
- 个
- 注册时间
- 2020-4-8
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
10明经币
请大神帮忙修改一下这个属性块提取到EXCEL表的源码,现在这个提取数据到EXCEL表,不能把相同的项合并,请大神帮忙改成可以合并相同项,后面还能统计出相同的项有多少。
*********************************************
(defun c:tSK () ;(/ 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)
)
)
|
附件: 您需要 登录 才可以下载或查看,没有账号?注册
评分
-
查看全部评分
|