明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1273|回复: 2

[提问] 帮忙看看这个提取属性块的程序!

[复制链接]
发表于 2014-10-23 17:20:52 | 显示全部楼层 |阅读模式
(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:能不能实现批量提取一个文件夹的数据!

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2014-10-23 17:36:47 | 显示全部楼层
看不出来...
 楼主| 发表于 2014-10-23 20:25:48 | 显示全部楼层
photo_cup 发表于 2014-10-23 17:36
看不出来...

!!!!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-5-23 23:27 , Processed in 0.249699 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表