Ahankhah 发表于 2022-7-6 09:08:05

我只想要方块而不是Xre

大家好,
 
我希望wblock所有块,即使没有插入,但作为命名对象存在。但是,当我使用tblsearch、tblnext时。。。函数,它们也返回外部参照。如何从上述函数返回的名称列表中区分块?
 
提前谢谢。

pBe 发表于 2022-7-6 09:13:08

TBL搜索
 
适用于常规块
 

(< (logior 2 (cdr (assoc 70 (tblsearch "BLOCK" "XrefBlock")))) 3)
(< (logior 2 (cdr (assoc 70 (tblsearch "BLOCK" "RegularBlock")))) 3)


 
TBL下一步
 

(< (logior 2 (cdr(assoc 70 (tblnext "BLOCK")))) 3)

Tharwat 发表于 2022-7-6 09:15:25

这可能会奏效。
 

(defun c:ExportBlks (/ blk l ss)
;; Tharwat 23. 07. 2011
(while
   (setq blk (tblnext "BLOCK" (null blk)))
    (member (cdr (assoc 2 blk))
            (setq l (cons (cdr (assoc 2 blk)) l))
    )
)
(setq ss (ssadd))
(foreach x l
   (command "_.-insert" x '(0. 0. 0.) "" "" "")
   (ssadd (entlast) ss)
)
(command "._wblock"
          (strcat (getvar 'dwgprefix) "DrawingName.dwg")
          ""
          "_Non"
          '(0.0 0.0 0.0)
          ss
          ""
)
(command "_.erase" (sssetfirst nil ss) "")
(princ)
)

 
塔瓦特

pBe 发表于 2022-7-6 09:20:34

塔尔瓦特。。
 
 
您需要过滤列表以排除外部参照,并且通过适当的功能,您不需要在调用Wblock之前插入块。
研究WBLOCK方法
 
 
或在此处提供块名称

Enter name of existing block or
[= (block=output file)/* (whole drawing)] <define new drawing>:

Tharwat 发表于 2022-7-6 09:23:54

我想外部参照块不能通过insert命令插入,这就是为什么我使用它来避免选择外部参照。

pBe 发表于 2022-7-6 09:25:49

关键是不要像“INSERT”“ERASE”那样调用不必要的行。简单的测试会告诉您它不是外部参照
 

(< (logior 2 (cdr(assoc 70 (tblnext "BLOCK")))) 3)

Ahankhah 发表于 2022-7-6 09:30:15

pBe和Tharwat,谢谢你们的帮助。
我会试试的。

Tharwat 发表于 2022-7-6 09:32:18

 
如果OP希望使用ssget“_x”选择所有块并对其进行过滤以避免外部参照,那么这是正确的,并对此进行检查。
 

pBe 发表于 2022-7-6 09:35:46

最好的方法是不通过选择而是从块表中创建块列表。
 
SSGET不会选择未插入的块
 
您可以只提供块名(过滤列表后),而不选择块本身。光是名字就足够了
 
因此无需调用插入和擦除
 
像这样的
(while
(setq blk (tblnext "BLOCK" (null blk)))
(if (< (logior 2 (cdr(assoc 70 blk))) 3)
(command "._wblock" (strcat "d:\\path\\" (setq nm (cdr (assoc 2 blk)))) nm )))

 
编辑:
 
(defun c:WBBlock(/ blk ChkNme nm)
   (while
         (setq blk (tblnext "BLOCK" (null blk)))
                (if (< (logior 2 (cdr (assoc 70 blk))) 3)
                      (progn
                            (command
                                  "._wblock"
                                  (setq ChkNme (strcat
                                                   "d:\\path\\"
                                                   (setq nm   (cdr(assoc 2 blk)))
                                                   ".dwg")))
                            (while (> (getvar 'cmdactive) 0)
                                  (if (findfile ChkNme)
                                        (command "Y" nm)
                                        (command nm)))
                            )
                      )
                )
   )

Tharwat 发表于 2022-7-6 09:39:19

pBe您的例程将每个块写入一个单独的图形,该图形只包含一个块。
 
当做
页: [1] 2
查看完整版本: 我只想要方块而不是Xre