请求大神修改下补充修改下属性块提取到EXCEL表的源码!!!
本帖最后由 q2284555 于 2022-11-6 17:46 编辑请大神帮忙修改一下这是属性块提取到EXCEL表的源码。
请大神帮忙补充修改下,1.补充提取块名称和坐标2.固定提取全图内名为“电缆统计1”和“G-DZPJT1”这两种属性块~! !!
==============================================
(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)
)
)
q2284555 发表于 2022-11-6 17:48
或者可以在图内选择这两种属性块~~~
瞎改一通嘿嘿嘿
或者可以在图内选择这两种属性块~~~ xj6019 发表于 2022-11-6 19:07
瞎改一通嘿嘿嘿
可以补充下表头名称,块名称和坐标吗? 如果可以实现2种块的数据能分开列输出就棒了。 补充下表头也行,自顶一下。
页:
[1]