- 积分
- 733
- 明经币
- 个
- 注册时间
- 2022-10-14
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
5明经币
这是属性块导出属性值、块、XY坐标到exce打开(csv格式)的插件, 还差个块名称、坐标表头没补充。 技术太水,研究了下不得要领,望高人指点。
(defun c:N88 (/ atts d f filename n obj r ss) ;(/ d r ss n obj atts)
(setq atts nil)
(while (setq d (tblnext "block" (null d)))
(setq r (cons (cdr (assoc 2 d)) r))
)
(setq dizhi "C:/Users/Administrator/Desktop/校验888.csv")
(and r
(setq filename (getfiled "属性输出文件名" dizhi "csv" 32))
)
(if filename
(progn
(setq f (open filename "w"))
(setq ss (ssget "X" '((0 . "INSERT")(2 . "电缆统计1,G-DZPJT1,本册新电缆,本册新电缆1,他册新电缆,保存时间")))) ;选择对像,修改这里
;(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)
(LIST(LIST
(Vlax-Get obj 'InsertionPoint )
(Vlax-Get obj 'Name )
))
)
)
(princ (1+ n) f)
(princ "," f)
;(foreach att (reverse atts) ;;;同一列前后颠倒
(foreach att atts
(IF(listp ATT)
(progn
(princ (CADR ATT) f)
(princ "," f)
(princ (car(CAR ATT)) f)
(princ "," f)
(princ (cadr(CAR ATT)) f)
)
(princ (vla-get-TextString att) f)
)
(princ "," f)
)
(princ "\n" f) ;写出属性值
)
(close f)
)
)
)
;(close f)
)
(vlax-invoke
(vlax-get-or-create-object "Wscript.Shell")
'RUN
dizhi );打开文件代码
)
|
附件: 您需要 登录 才可以下载或查看,没有账号?注册
最佳答案
查看完整内容
这么执着干嘛呀,凑合能用就行了呗!!!
(defun c:NM (/ atts d dizhi f filename n obj r ss) ;(/ d r ss n obj atts)
(setq atts nil)
(while (setq d (tblnext "block" (null d)))
(setq r (cons (cdr (assoc 2 d)) r))
)
(setq dizhi "C:/Users/Administrator/Desktop/校验888.csv")
(and r
(setq filename (getfiled "属性输出文件名" dizhi "csv" 32))
)
(if filename
(p ...
|