乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 80|回复: 6

[编程交流] 在多个绘图中移动块

[复制链接]

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 15:38:41 | 显示全部楼层 |阅读模式
你好
 
我有一个问题,我有许多图纸,其中包含相同的块,应该被隐藏的数字。根据其他线程的提示,我提出了以下解决方案,我不知道如何利用。
 
首先->我使用lisp创建新层,然后将具有相同名称的块移动到此层。例如:
 
  1. (vl-load-com) ;Load VLisp extensions
  2. ;; Function to change bllocks to a layer by wildcard
  3. (defun Blk2Lay (LName ss / n en eo)
  4. (if (not (tblobjname "LAYER" LName)) ;Check if layer doesn't exist
  5.    (command "._LAYER" "_Make" LName "") ;Make the layer
  6. ) ;_ end of if
  7. (setq n (sslength ss)) ;Initialize counter
  8. (while (>= (setq n (1- n)) 0) ;Step through all entities in selection set
  9.    (setq en (ssname ss n) ;Get the nth EName
  10.          eo (vlax-ename->vla-object en) ;Get the ActiveX object
  11.    ) ;_ end of setq
  12.    (vla-put-Layer eo LName) ;Change block reference to new layer
  13. ) ;_ end of while
  14. ) ;_ end of defun
  15. ;; Command to change blocks to a layer by wildcard
  16. (defun c:Blk2Lay (/ LName BWild ss)
  17. (if (setq LName (getstring "Enter the layer's name: ")) ;Get the layer's name
  18.    (if (and
  19.          (or
  20.            (and (= (setq BWild (getstring ;Get wildcard, default as layer name
  21.                                  (strcat "Enter the wildcard for the block name <*" LName "*>: ")
  22.                                ) ;_ end of getstring
  23.                    ) ;_ end of setq
  24.                    ""
  25.                 ) ;_ end of =
  26.                 (setq BWild (strcat "*" LName "*")) ;Default to LName
  27.            ) ;_ end of and
  28.            (and BWild (/= BWild ""))
  29.          ) ;_ end of or
  30.          (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 BWild)))) ;And some blocks found
  31.        ) ;_ end of and
  32.      (Blk2Lay LName ss) ;Perform the change
  33.    ) ;_ end of if
  34. ) ;_ end of if
  35. (princ)
  36. ) ;_ end of defun
  37. Second - > I changed property of this layer to non visible.
  38. Third - > I applied above changes on selected drawings.
  39. 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:
  40. //This is example of script which remove blocks with name "KOLKO' from selected drawings
  41. (defun c:dbtest ( / lst )
  42.    (if (setq lst (LM:getfiles "Select Drawings to Process" nil "dwg;dws;dwt"))
  43.        (LM:odbx '(lambda ( doc ) (LM:deleteblocks doc '("KOLKO"))) lst t)
  44.        (princ "\n*Cancel*")
  45.    )
  46.    (princ)
  47. )

 
有谁能帮我解决我的问题吗?
回复

使用道具 举报

10

主题

8258

帖子

8335

银币

初来乍到

Rank: 1

铜币
31
发表于 2022-7-5 15:49:56 | 显示全部楼层
“隐藏”层是关闭还是冻结?
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 16:05:28 | 显示全部楼层
在这种情况下,这无关紧要。它们可能被隐藏或冻结。我只想保留这些积木,但不想移除它们
回复

使用道具 举报

10

主题

8258

帖子

8335

银币

初来乍到

Rank: 1

铜币
31
发表于 2022-7-5 16:18:14 | 显示全部楼层
我认为这会有所不同。您可能希望为希望帮助您测试其代码的任何人提供一个样例绘图。具体说明哪些块必须“隐藏”以及您喜欢的方法。我们需要一个。dwg文件不是图像文件。
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 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,因此这就是我很难了解其工作原理的原因:/
回复

使用道具 举报

4

主题

2143

帖子

2197

银币

限制会员

铜币
-24
发表于 2022-7-5 16:31:46 | 显示全部楼层
请阅读代码发布指南,并编辑代码以包含在代码标签中。[NOPARSE]
  1. Your Code Here[/NOPARSE]
=
  1. Your Code Here
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:47:22 | 显示全部楼层
简单的图层情况(命令“-layer”“off”layername”“)或冻结。也可以使用通配符-layer off k*
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-12 18:59 , Processed in 1.035294 second(s), 66 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表