明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1042|回复: 1

[提问] 综合炸开清理【程序出错】

[复制链接]
发表于 2018-6-28 12:59:02 | 显示全部楼层 |阅读模式
本帖最后由 尘缘一生 于 2018-6-28 13:00 编辑

2018版,不能使用,错误提示如下:

调用(*push-error-using-command*)前无法从 *error* 调用(command)。
建议将(command)调用转换为(command-s)。
命令:



请高手分析下,哪里原因?


  1. ;;---炸开清理全图-------------------------------------------------------------------------

  2. (defun C:T-EXPLODE(/ s p n l nam stlx r_zm70 c_zm71 r_dist_zm44 c_dist_zm45 e)
  3.   ;; 炸开属性块,属性转文字
  4.   (setq s nil)
  5.   (if (setq s(ssget "X" (list (cons 0 "INSERT")(cons 66 1))))
  6.     (progn   
  7.       (vl-load-com)
  8.       (setq p(sslength s))
  9.       (setq n 0 )
  10.       (undobegin)         
  11.       (setq p(- p 1))
  12.       (while (<= n p)
  13.         (a2t (ssname s n))            
  14.         (setq n (+ n 1))
  15.         (undoend)
  16.       )
  17.     )
  18.   )
  19.   ;;转多重插入块为普通快
  20.   (setvar "cmdecho" 0)
  21.   (setq s nil)
  22.   (if (setq s(ssget "X" (list (cons 0 "INSERT")(cons 100 "AcDbMInsertBlock"))))   
  23.     (progn      
  24.       (setq p(sslength s))
  25.       (setq n 0 )
  26.       (setq p (- p 1))
  27.       (while (<= n p)
  28.         (setq nam(ssname s n))
  29.         (setq e (entget nam))
  30.         (setq stlx (cdr (assoc 0 e)))            
  31.         (setq r_zm70 (assoc 70 e))
  32.         (setq c_zm71 (assoc 71 e))
  33.         (setq r_dist_zm44 (assoc 44 e))
  34.         (setq c_dist_zm45 (assoc 45 e))
  35.         (setq e (subst (cons 44 0) r_dist_zm44 e))
  36.         (setq e (subst (cons 45 0) c_dist_zm45 e))
  37.         (setq e (subst (cons 70 0) r_zm70 e))
  38.         (setq e (subst (cons 71 0) c_zm71 e))
  39.         (setq e (subst (list 100 "AcDbBlockReference") (list 100 "AcDbMInsertBlock") e))
  40.         (entmake e)
  41.         (entdel nam)
  42.         (setq n (+ n 1))
  43.       )
  44.     )
  45.   )
  46.   ;; 炸开存在普通块、MTEXT字体,,,,,,,,,,
  47.   (setq s nil)
  48.   (if (setq s(ssget "X" (list (cons 0 "MTEXT,DIM*,TCH*,INSERT"))))   
  49.     (progn      
  50.       (setq p(sslength s))
  51.       (setq n 0 )
  52.       (setq p (- p 1))
  53.       (while (<= n p)
  54.         (setq nam(ssname s n))
  55.         (command "EXPLODE" nam "")
  56.         (setq n (+ n 1))
  57.       )
  58.     )
  59.   )
  60.   (setvar "cmdecho" 1)
  61.   (command "_.PURGE" "a" "*" "N")
  62.   (csh)
  63.   (command "-scalelistedit" "R" "Y" "E") ;;清理注释比例
  64.   (command "regenall")
  65. )
  66. ;;; ***********************************************************************
  67. ;;以下是属性转文字函数
  68. (defun undobegin ()
  69.   (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
  70.   (vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
  71. )
  72. ;;--------------------------------------------------------------
  73. (defun undoend ()
  74.   (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
  75. )
  76. ;;--------------------------------------------------------------
  77. (defun dxf (code elist)
  78.   (cdr (assoc code elist))
  79. )
  80. ;;--------------------------------------------------------------
  81. (defun makeobject (obj)
  82.   (cond
  83.     ((= (type obj) 'vla-object)
  84.       obj
  85.     )
  86.     ((= (type obj) 'ename)
  87.       (vlax-ename->vla-object obj)
  88.     )
  89.   )
  90. )
  91. ;;--------------------------------------------------------------
  92. (defun explode1 (obj / temp)
  93.   (setq temp (vla-explode obj))
  94.   (vla-delete obj)
  95.   temp
  96. )
  97. ;;--------------------------------------------------------------
  98. (defun vararray->list (vaobj)
  99.   (vlax-safearray->list (vlax-variant-value vaobj))
  100. )
  101. ;;--------------------------------------------------------------
  102. (defun a2t (obj / attlist attobj txt txtpt just inspt height width rot genflag layr ent idx objlist style space tmp upsid bkwd ltyp
  103.              colr attlyr attcol
  104.            )
  105.   (if (and
  106.         (= (dxf 0 (entget obj)) "INSERT")
  107.         (setq obj (makeobject obj))
  108.       )
  109.     (if (= (vla-get-hasattributes obj) :vlax-true)
  110.       (progn
  111.         (setq attlist (vararray->list (vla-getattributes obj))
  112.           idx 0
  113.           layr (vla-get-layer obj)
  114.           ltyp (vla-get-linetype obj)
  115.           colr (vla-get-color obj)
  116.         )
  117.         (repeat (length attlist)
  118.           (setq attobj (nth idx attlist)
  119.             txt (append
  120.                   txt
  121.                   (list (vla-get-textstring attobj))
  122.                 )
  123.             txtpt (append
  124.                     txtpt
  125.                     (list (vla-get-textalignmentpoint attobj))
  126.                   )
  127.             inspt (append
  128.                     inspt
  129.                     (list (vla-get-insertionpoint attobj))
  130.                   )
  131.             just (append
  132.                    just
  133.                    (list (vla-get-alignment attobj))
  134.                  )
  135.             height (append
  136.                      height
  137.                      (list (vla-get-height attobj))
  138.                    )
  139.             width (append
  140.                     width
  141.                     (list (vla-get-scalefactor attobj))
  142.                   )
  143.             rot (append
  144.                   rot
  145.                   (list (vla-get-rotation attobj))
  146.                 )
  147.             style (append
  148.                     style
  149.                     (list (vla-get-stylename attobj))
  150.                   )
  151.             upsid (append
  152.                     upsid
  153.                     (list (vla-get-upsidedown attobj))
  154.                   )
  155.             bkwd (append
  156.                    bkwd
  157.                    (list (vla-get-backward attobj))
  158.                  )
  159.             attlyr (append
  160.                      attlyr
  161.                      (list (vla-get-layer attobj))
  162.                    )
  163.             attcol (append
  164.                      attcol
  165.                      (list (vla-get-color attobj))
  166.                    )
  167.             idx (1+ idx)
  168.           )
  169.         )
  170.         (setq objlist (vararray->list (explode1 obj))
  171.           idx 0
  172.         )
  173.         (repeat (length objlist)
  174.           (setq ent (dxf 0 (entget (vlax-vla-object->ename (nth idx objlist)))))
  175.           (if (= ent "ATTDEF")
  176.             (vla-erase (nth idx objlist))
  177.             (if (= (vla-get-layer (nth idx objlist)) "0")
  178.               (progn
  179.                 (vla-put-layer (nth idx objlist) layr)
  180.                 (vla-put-linetype (nth idx objlist) ltyp)
  181.                 (vla-put-color (nth idx objlist) colr)
  182.               )
  183.             )
  184.           )
  185.           (setq idx (1+ idx))
  186.         )
  187.         (setq space (if (= (vla-get-activespace (vla-get-activedocument (vlax-get-acad-object))) acmodelspace)
  188.                       (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
  189.                       (vla-get-paperspace (vla-get-activedocument (vlax-get-acad-object)))
  190.                     )
  191.           idx 0
  192.         )
  193.         (repeat (length attlist)
  194.           (setq tmp (vla-addtext space (nth idx txt) (nth idx inspt) (nth idx height)))
  195.           (vla-put-alignment tmp (nth idx just))
  196.           (if (and
  197.                 (/= (nth idx just) acalignmentleft)
  198.                 (/= (nth idx just) acalignmentfit)
  199.                 (/= (nth idx just) acalignmentaligned)
  200.               )
  201.             (vla-move tmp (vla-get-textalignmentpoint tmp) (nth idx txtpt))
  202.             (progn
  203.               (vla-move tmp (vla-get-insertionpoint tmp) (nth idx inspt))
  204.               (vla-put-alignment tmp acalignmentleft)
  205.             )
  206.           )
  207.           (vla-put-rotation tmp (nth idx rot))
  208.           (vla-put-scalefactor tmp (nth idx width))
  209.           (vla-put-stylename tmp (nth idx style))
  210.           (if (/= (nth idx attlyr) "0")
  211.             (vla-put-layer tmp (nth idx attlyr))
  212.             (vla-put-layer tmp layr)
  213.           )
  214.           (if (/= (nth idx attlyr) "0")
  215.             (vla-put-color tmp (nth idx attcol))
  216.             (vla-put-color tmp colr)
  217.           )
  218.           (cond
  219.             ((and
  220.                (= (nth idx upsid) :vlax-true)
  221.                (= (nth idx bkwd) :vlax-false)
  222.              )
  223.               (vla-put-textgenerationflag tmp actextflagupsidedown)
  224.             )
  225.             ((and
  226.                (= (nth idx upsid) :vlax-false)
  227.                (= (nth idx bkwd) :vlax-true)
  228.              )
  229.               (vla-put-textgenerationflag tmp actextflagbackward)
  230.             )
  231.             ((and
  232.                (= (nth idx upsid) :vlax-true)
  233.                (= (nth idx bkwd) :vlax-true)
  234.              )
  235.               (vla-put-textgenerationflag tmp (+ actextflagbackward actextflagupsidedown))
  236.             )
  237.           )
  238.           (setq idx (1+ idx))
  239.         )
  240.       )
  241.     )
  242.   )
  243.   (undoend)
  244. )
  245. ;;;;属性转文字函数结束
  246. ;;----------------------------------------------------------------------------



本帖子中包含更多资源

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

x
"觉得好,就打赏"
还没有人打赏,支持一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-19 14:01 , Processed in 0.177898 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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