明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: 77077

[源码] 块属性提取到excel [已解决]

  [复制链接]
 楼主| 发表于 2014-2-24 22:01 | 显示全部楼层
完美解决,感谢Gu_xl
发表于 2014-5-13 07:10 | 显示全部楼层
虽然不明白,努力学习中。。。,楼主辛苦,支持原创
发表于 2014-5-14 07:04 | 显示全部楼层
再次拜读,
发表于 2014-10-28 18:34 | 显示全部楼层
学习了
发表于 2014-12-17 22:23 | 显示全部楼层
(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 '((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 atts
          (princ (vla-get-TextString att) f) (princ "," f)
          )
        (princ "\n" f);写出属性值
        )
      )
      )
    )
      (close f)
  )
    )
  )

在AUTOCAD 2011版本中无法正常使用不晓得什么缘故?
发表于 2014-12-19 08:02 | 显示全部楼层
(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资料与图面属性块上下颠倒,还需要修正?
发表于 2016-4-9 10:24 | 显示全部楼层
怎样获取块的比例,想做一个块比例的格式刷
发表于 2016-6-1 16:55 | 显示全部楼层
复制了学习学习
发表于 2016-6-1 16:56 | 显示全部楼层
看看啊看看看卡按啊
发表于 2016-6-4 17:33 | 显示全部楼层
真的不错——谢谢————
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-20 07:35 , Processed in 0.470501 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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