mstg007 发表于 2015-3-17 09:49:01

在其他图形中插入块

我试图通过使用脚本设置(命令行)来解决这个问题;如果我有一个包含多个块的图形,我想编写一个脚本,可以找到该图形并查找请求块的名称,然后将其插入到当前图形中。我知道你可以通过工具选项板来实现,但我还是希望能够实现自动化;;source http://www.theswamp.org/index.php?topic=47103.0
(defun c:exportblocks (/ blk blks x dir)
(vl-load-com)
(if (setq blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
    (progn (setvar 'filedia 0)
         (setq dir (strcat (getvar 'dwgprefix) "_ExportedBlocks\\"))
         (vl-mkdir dir)
         (vlax-for blk blks
             (if (and (not (wcmatch (setq x (vla-get-name blk)) "*|*,*`**"))
                      (= (vla-get-isxref blk) :vlax-false)
               )
               (progn
               (annotativeblock x)
               (command "._-wblock" (strcat dir x) x)
                   )
             )
         )
         (setvar 'filedia 1)
    )
)
(princ)
)

(defun annotativeblock ( blk )
    (and (setq blk (tblobjname "block" blk))
      (progn
            (regapp "AcadAnnotative")
            (entmod
                (append (entget (cdr (assoc 330 (entget blk))))
                   '(
                        (   -3
                            (   "AcadAnnotative"
                              (1000 . "AnnotativeData")
                              (1002 . "{")
                              (1070 . 0)
                              (1070 . 0)
                              (1002 . "}")
                            )
                        )
                  )
                )
            )
      )
    )
)

mjfarrell 发表于 2015-3-17 09:49:55

棒!
我也偶然发现了这一点...以为我分享。
http://www.cadtutor.net/forum/archive/index.php/t-55084.html?s=441b729217477d67f32aa206ececea1b
页: [1]
查看完整版本: 在其他图形中插入块