明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3694|回复: 19

求助帖(属性块--->文字)

  [复制链接]
发表于 2009-12-26 20:18:00 | 显示全部楼层 |阅读模式

习惯使用cad文字,希望将图中属性定义块炸开,里面文字保留不变。请大侠出手帮忙。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2013-1-21 21:25:33 | 显示全部楼层
楼上意见有人说了,BURST,CAD自带的
回复 支持 1 反对 0

使用道具 举报

发表于 2019-4-20 16:56:13 | 显示全部楼层
发表于 2009-12-26 21:27:00 | 显示全部楼层
  1. ;;;***********************************************************************
  2. ;;; ATT2TXT.LSP
  3. ;;; 通用处理函数. 可以将带属性的块爆炸,并将属性转换成文字
  4. ;;;***********************************************************************
  5. (vl-load-com)
  6. ;;;*********************************************************************
  7. ;;; 用于该程序的使用函数
  8. ;;;*********************************************************************
  9. (defun UndoBegin ()
  10.   (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
  11.   (vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
  12. )
  13. (defun UndoEnd ()
  14.   (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
  15. )
  16. (defun DXF (code elist) (cdr (assoc code elist)))
  17. (defun MakeObject (obj)
  18.   (cond
  19.     ( (= (type obj) 'VLA-OBJECT) obj)
  20.     ( (= (type obj) 'ENAME) (vlax-ename->vla-object obj))
  21.   )
  22. )
  23. (defun Explode (obj / temp)
  24.   (setq temp (vla-explode obj))
  25.   (vla-delete obj)
  26.   temp
  27. )
  28. (defun VarArray->List (vaobj)
  29.   (vlax-SafeArray->List
  30.     (vlax-Variant-Value vaobj)
  31.   )
  32. )
  33. ;;;***************************************************************************
  34. ;;; 命令行调用函数...
  35. ;;;***************************************************************************
  36. (defun C:ATT2TXT (/ ss i)
  37.   (princ "\n选择一个属性块转成文字...")
  38.   (if (setq ss (ssget (list (cons 0 "INSERT"))))
  39.     (progn
  40.       (setq i  0)
  41.       (UndoBegin)
  42.       (repeat (sslength ss)
  43.         (A2T (ssname ss i))
  44.         (setq i (1+ i))
  45.       )
  46.       (UndoEnd)
  47.     )
  48.   )
  49.   (princ)
  50. )
  51. ;;;***********************************************************************
  52. ;;; 主函数...
  53. ;;;***********************************************************************
  54. (defun A2T (obj / attlist attobj txt txtpt just inspt height width rot genflag
  55.                   layr ent idx objList style space tmp upsid bkwd ltyp colr
  56.                   attlyr attcol
  57.            )
  58.   (if
  59.     (and
  60.       (= (DXF 0 (entget obj)) "INSERT")
  61.       (setq obj (MakeObject obj))
  62.     )
  63.    (if (= (vla-get-hasattributes obj) :vlax-true)
  64.     (progn
  65.         (setq attlist (varArray->List (vla-GetAttributes obj))
  66.               idx     0
  67.               layr    (vla-get-layer obj)
  68.               ltyp    (vla-get-linetype obj)
  69.               colr    (vla-get-color obj)
  70.         )
  71.         (repeat (length attlist)
  72.           (setq attobj (nth idx attlist)
  73.                 txt    (append txt     (list (vla-get-textstring attobj)))
  74.                 txtpt  (append txtpt   (list (vla-get-textalignmentpoint attobj)))
  75.                 inspt  (append inspt   (list (vla-get-insertionpoint attobj)))
  76.                 just   (append just    (list (vla-get-alignment attobj)))
  77.                 height (append height  (list (vla-get-height attobj)))
  78.                 width  (append width   (list (vla-get-scalefactor attobj)))
  79.                 rot    (append rot     (list (vla-get-rotation attobj)))
  80.                 style  (append style   (list (vla-get-stylename attobj)))
  81.                 upsid  (append upsid   (list (vla-get-upsidedown attobj)))
  82.                 bkwd   (append bkwd    (list (vla-get-backward attobj)))
  83.                 attlyr (append attlyr  (list (vla-get-layer attobj)))
  84.                 attcol (append attcol  (list (vla-get-color attobj)))
  85.                 idx    (1+ idx)
  86.           )
  87.         )
  88.         (setq objList (varArray->List (Explode obj))
  89.               idx     0
  90.         )
  91.         (repeat (length objList)
  92.           (setq ent (DXF 0 (entget (vlax-vla-object->ename (nth idx objList)))))
  93.           (if (= ent "ATTDEF")
  94.             (vla-erase (nth idx objList))
  95.           (if
  96.               (= (vla-get-layer (nth idx objList)) "0")
  97.             (progn
  98.                 (vla-put-layer (nth idx objList) layr)
  99.                 (vla-put-linetype (nth idx objList) ltyp)
  100.                 (vla-put-color (nth idx objList) colr)
  101.               )
  102.           )
  103.           )
  104.           (setq idx (1+ idx))
  105.         )
  106.         (setq space (if (= (vla-get-activespace (vla-get-activedocument (vlax-get-acad-object))) acModelspace)
  107.                   (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))
  108.                   (vla-get-PaperSpace (vla-get-ActiveDocument (vlax-get-acad-object)))
  109.                 )
  110.               idx   0
  111.         )
  112.         (repeat (length attlist)
  113.           (setq tmp (vla-addText space (nth idx txt) (nth idx inspt) (nth idx height)))
  114.           (vla-put-alignment tmp (nth idx just))
  115.           (if
  116.             (and
  117.               (/= (nth idx just) acAlignmentLeft)
  118.               (/= (nth idx just) acAlignmentFit)
  119.               (/= (nth idx just) acAlignmentAligned)
  120.             )
  121.             (vla-move tmp (vla-get-TextAlignmentPoint tmp) (nth idx txtpt))
  122.             (progn
  123.               (vla-move tmp (vla-get-InsertionPoint tmp) (nth idx inspt))
  124.               (vla-put-alignment tmp acAlignmentLeft)
  125.             )
  126.           )
  127.           (vla-put-rotation tmp (nth idx rot))
  128.           (vla-put-scalefactor tmp (nth idx width))
  129.           (vla-put-stylename tmp (nth idx style))
  130.           (if (/= (nth idx attlyr) "0") (vla-put-layer tmp (nth idx attlyr)) (vla-put-layer tmp layr))
  131.           (if (/= (nth idx attlyr) "0") (vla-put-color tmp (nth idx attcol)) (vla-put-color tmp colr))
  132.           (cond
  133.             ( (and (= (nth idx upsid) :vlax-true) (= (nth idx bkwd) :vlax-false))
  134.               (vla-put-textgenerationflag tmp acTextFlagUpsideDown)
  135.             )
  136.             ( (and (= (nth idx upsid) :vlax-false) (= (nth idx bkwd) :vlax-true))
  137.               (vla-put-textgenerationflag tmp acTextFlagBackward)
  138.             )
  139.             ( (and (= (nth idx upsid) :vlax-true) (= (nth idx bkwd) :vlax-true))
  140.               (vla-put-textgenerationflag tmp (+ acTextFlagBackward acTextFlagUpsideDown))
  141.             )
  142.           )
  143.           (setq idx (1+ idx))
  144.         )
  145.         (princ "\n属性已经转换.")
  146.       )
  147.       (princ "\n所需对象没有属性可提取")
  148.   )
  149.     (princ "\n所选实体不是块对象!")
  150.   )
  151.   (UndoEnd)
  152.   (princ)
  153. )
  154. ;;***********************************************************************
  155. (princ)

点评

这个程序最好改写成自动全图工作的,不用选择就好啦!  发表于 2015-2-7 21:18

评分

参与人数 1明经币 +1 收起 理由
自贡黄明儒 + 1

查看全部评分

 楼主| 发表于 2009-12-27 16:39:00 | 显示全部楼层

真的很好用,真的很感谢xianaihua大侠帮忙,比我期望的还快,比我期望的要好。

收藏了,向xianaihua大侠学习!

发表于 2009-12-27 16:57:00 | 显示全部楼层
et工具中命令burst
发表于 2009-12-27 17:00:00 | 显示全部楼层

新手顶,我也很想用用看

发表于 2010-10-1 00:03:00 | 显示全部楼层
真是好用,非常不错
发表于 2010-10-1 00:04:00 | 显示全部楼层
很实用
发表于 2010-10-1 00:04:00 | 显示全部楼层

支持一下

 

发表于 2010-11-19 14:34:00 | 显示全部楼层

[原创]有没有比较方便的CAD线形制作工具

收藏收藏。好贴收藏
发表于 2010-12-31 15:13:30 | 显示全部楼层
大家都说好才是真的好
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-18 22:56 , Processed in 0.209666 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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