MISAH 发表于 2022-7-5 15:38:41

在多个绘图中移动块

你好
 
我有一个问题,我有许多图纸,其中包含相同的块,应该被隐藏的数字。根据其他线程的提示,我提出了以下解决方案,我不知道如何利用。
 
首先->我使用lisp创建新层,然后将具有相同名称的块移动到此层。例如:
 
(vl-load-com) ;Load VLisp extensions
;; Function to change bllocks to a layer by wildcard
(defun Blk2Lay (LName ss / n en eo)
(if (not (tblobjname "LAYER" LName)) ;Check if layer doesn't exist
   (command "._LAYER" "_Make" LName "") ;Make the layer
) ;_ end of if
(setq n (sslength ss)) ;Initialize counter
(while (>= (setq n (1- n)) 0) ;Step through all entities in selection set
   (setq en (ssname ss n) ;Get the nth EName
         eo (vlax-ename->vla-object en) ;Get the ActiveX object
   ) ;_ end of setq
   (vla-put-Layer eo LName) ;Change block reference to new layer
) ;_ end of while
) ;_ end of defun

;; Command to change blocks to a layer by wildcard
(defun c:Blk2Lay (/ LName BWild ss)
(if (setq LName (getstring "Enter the layer's name: ")) ;Get the layer's name
   (if (and
         (or
         (and (= (setq BWild (getstring ;Get wildcard, default as layer name
                                 (strcat "Enter the wildcard for the block name <*" LName "*>: ")
                               ) ;_ end of getstring
                   ) ;_ end of setq
                   ""
                ) ;_ end of =
                (setq BWild (strcat "*" LName "*")) ;Default to LName
         ) ;_ end of and
         (and BWild (/= BWild ""))
         ) ;_ end of or
         (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 BWild)))) ;And some blocks found
       ) ;_ end of and
   (Blk2Lay LName ss) ;Perform the change
   ) ;_ end of if
) ;_ end of if
(princ)
) ;_ end of defun

Second - > I changed property of this layer to non visible.

Third - > I applied above changes on selected drawings.

Based on another example I found that there is possible to use LISP getfiles as well as ObjectDBX Wrapper which allow to use another function like below:

//This is example of script which remove blocks with name "KOLKO' from selected drawings
(defun c:dbtest ( / lst )
   (if (setq lst (LM:getfiles "Select Drawings to Process" nil "dwg;dws;dwt"))
       (LM:odbx '(lambda ( doc ) (LM:deleteblocks doc '("KOLKO"))) lst t)
       (princ "\n*Cancel*")
   )
   (princ)
)
 
有谁能帮我解决我的问题吗?

ReMark 发表于 2022-7-5 15:49:56

“隐藏”层是关闭还是冻结?

MISAH 发表于 2022-7-5 16:05:28

在这种情况下,这无关紧要。它们可能被隐藏或冻结。我只想保留这些积木,但不想移除它们

ReMark 发表于 2022-7-5 16:18:14

我认为这会有所不同。您可能希望为希望帮助您测试其代码的任何人提供一个样例绘图。具体说明哪些块必须“隐藏”以及您喜欢的方法。我们需要一个。dwg文件不是图像文件。

MISAH 发表于 2022-7-5 16:27:56

现在,我只能尝试使用与我的主要例子类似的例子来更详细地解释我的问题。当然,我的作品数量要大得多。
 
实例我有三幅画——假设:
1.dwg-同一块名为“KOLKO”的2个OBEJCT,位于0层。例如,块表示放置在某处两次的圆。
2.dwg-1名为“KOLKO”的区块对象-0层。
3.dwg-名为“-0层的块的5个对象。
 
另一个物体如果存在的话,不要管我。现在我打开文件1。dwg和我想将块“KOLKO”的所有对象移动到新层,例如TEST,并将该层设置为隐藏。在不打开另一个图形的情况下重复此操作。
 
使用LISPhttp://www.lee-mac.com/getfilesdialog.html我可以选择应用哪些图形(在本例中为1.dwg、2.dwg、3.dwg)。然后使用LISPhttp://www.lee-mac.com/odbxbase.html我想利用脚本(第一篇文章中显示的代码),它允许创建新层,并根据块的名称选择要移动的对象。不幸的是,我也不知道如何更改隐藏选项的图层属性。
 
也许有更简单的方法,因为我看到了scirpt,它允许通过选择其中一个来将块的所有对象移动到另一层。但存在一个约束,即目标层必须存在于所有图形中。但这不是一个问题,因为我知道如何用另一种方式来做,而不需要使用LISP来更改隐藏层。但我仍然不知道如何使用LISP在所有选定的图形上应用特定的scipthttp://www.lee-mac.com/odbxbase.html
 
 
我不熟悉LISP,因此这就是我很难了解其工作原理的原因:/

SLW210 发表于 2022-7-5 16:31:46

请阅读代码发布指南,并编辑代码以包含在代码标签中。
Your Code Here=
Your Code Here

BIGAL 发表于 2022-7-5 16:47:22

简单的图层情况(命令“-layer”“off”layername”“)或冻结。也可以使用通配符-layer off k*
页: [1]
查看完整版本: 在多个绘图中移动块