乐筑天下

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

[编程交流] 块元素和块到“

[复制链接]

3

主题

15

帖子

12

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 23:39:32 | 显示全部楼层 |阅读模式
嗨,任何人都可以编辑这个Lisp程序。。
 
此Lisp将我的块元素(块内的元素)转换为所需的层,但块(主块)层保持不变。。。
 
我想更改块元素、嵌套块元素和要在“0”或“所需层”中更改的块
 
我只是不知道如何改变块层。。。
 
 
  1. (defun c:norm (/ *error* adoc lst_layer func_restore-layers)
  2. (defun *error* (msg)
  3.    (func_restore-layers)
  4.    (vla-endundomark adoc)
  5.    (princ msg)
  6.    (princ)
  7.    ) ;_ end of defun
  8. (defun func_restore-layers ()
  9.    (foreach item lst_layer
  10.      (vla-put-lock (car item) (cdr (assoc "lock" (cdr item))))
  11.      (vl-catch-all-apply
  12.        '(lambda ()
  13.           (vla-put-freeze
  14.             (car item)
  15.             (cdr (assoc "freeze" (cdr item)))
  16.             ) ;_ end of vla-put-freeze
  17.           ) ;_ end of lambda
  18.        ) ;_ end of vl-catch-all-apply
  19.      ) ;_ end of foreach
  20.    ) ;_ end of defun
  21. (vl-load-com)
  22. (vla-startundomark
  23.    (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
  24.    ) ;_ end of vla-startundomark
  25. (if (and (not (vl-catch-all-error-p
  26.                  (setq selset
  27.                         (vl-catch-all-apply
  28.                           (function
  29.                             (lambda ()
  30.                               (ssget '((0 . "INSERT")))
  31.                               ) ;_ end of lambda
  32.                             ) ;_ end of function
  33.                           ) ;_ end of vl-catch-all-apply
  34.                        ) ;_ end of setq
  35.                  ) ;_ end of vl-catch-all-error-p
  36.                ) ;_ end of not
  37.           selset
  38.           ) ;_ end of and
  39.    (progn
  40.      (vlax-for item (vla-get-layers adoc)
  41.        (setq
  42.          lst_layer (cons (list item
  43.                                (cons "lock" (vla-get-lock item))
  44.                                (cons "freeze" (vla-get-freeze item))
  45.                                ) ;_ end of list
  46.                          lst_layer
  47.                          ) ;_ end of cons
  48.          ) ;_ end of setq
  49.        (vla-put-lock item :vlax-false)
  50.        (vl-catch-all-apply
  51.          '(lambda () (vla-put-freeze item :vlax-false))
  52.          ) ;_ end of vl-catch-all-apply
  53.        ) ;_ end of vlax-for
  54.      (foreach blk_def
  55.               (mapcar
  56.                 (function
  57.                   (lambda (x)
  58.                     (vla-item (vla-get-blocks adoc) x)
  59.                     ) ;_ end of lambda
  60.                   ) ;_ end of function
  61.                 ((lambda (/ res)
  62.                    (foreach item (mapcar
  63.                                    (function
  64.                                      (lambda (x)
  65.                                        (vla-get-name
  66.                                          (vlax-ename->vla-object x)
  67.                                          ) ;_ end of vla-get-name
  68.                                        ) ;_ end of lambda
  69.                                      ) ;_ end of function
  70.                                    ((lambda (/ tab item)
  71.                                       (repeat (setq tab  nil
  72.                                                     item (sslength selset)
  73.                                                     ) ;_ end setq
  74.                                         (setq
  75.                                           tab
  76.                                            (cons
  77.                                              (ssname selset
  78.                                                      (setq item (1- item))
  79.                                                      ) ;_ end of ssname
  80.                                              tab
  81.                                              ) ;_ end of cons
  82.                                           ) ;_ end of setq
  83.                                         ) ;_ end of repeat
  84.                                       tab
  85.                                       ) ;_ end of lambda
  86.                                     )
  87.                                    ) ;_ end of mapcar
  88.                      (if (not (member item res))
  89.                        (setq res (cons item res))
  90.                        ) ;_ end of if
  91.                      ) ;_ end of foreach
  92.                    (reverse res)
  93.                    ) ;_ end of lambda
  94.                  )
  95.                 ) ;_ end of mapcar
  96.        (vlax-for ent blk_def
  97.          (vla-put-layer ent "0")
  98.          (vla-put-color ent 0)
  99.          (vla-put-lineweight ent aclnwtbyblock)
  100.          (vla-put-linetype ent "byblock")
  101.          ) ;_ end of vlax-for
  102.        ) ;_ end of foreach
  103.      (func_restore-layers)
  104.      (vla-regen adoc acallviewports)
  105.      ) ;_ end of progn
  106.    ) ;_ end of if
  107. (vla-endundomark adoc)
  108. (princ)
  109. ) ;_ end of defun
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 23:51:18 | 显示全部楼层
是否将图形中所有块中的所有对象更改为一个特定图层名?
回复

使用道具 举报

3

主题

15

帖子

12

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 23:51:49 | 显示全部楼层
如。。我必须选择所有家具对象和家具块(甚至嵌套块)到特定的层名称。。。
 
同样的事情,我必须做的机械和管道等。。。
回复

使用道具 举报

0

主题

301

帖子

301

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-5 23:59:46 | 显示全部楼层
你有没有试过Gille Chanteau的这个套路:
 
编辑_块
 
ymg公司
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 00:05:05 | 显示全部楼层
嗨,ymg。。。我检查了Gile的代码,确实发现了一些不足。。。在所有参照上选择缩放选项后,块在当前图形块集合中不会更新,因此我必须在例程的末尾添加两行:
 
除此之外,我已经成功地将DCL实现到LSP例程中,因此您不需要它,它都在lisp中-您可以轻松地将此例程添加到启动套件中,这就是我所做的。。。套路写得很好,所有这些都是对Gilles Chanteaux的赞扬。。。
 
M、 R。
(我会附上我的版本,供那些想下载和使用的人使用)
编辑块。lsp
回复

使用道具 举报

0

主题

301

帖子

301

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 00:14:28 | 显示全部楼层
谢谢Marko,
 
吉尔一直是一个伟大的!贡献者
 
ymg公司
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 00:20:42 | 显示全部楼层
是的,这一切都可以,但如果你检查例行程序,它不会回应OP的请求。。。
 
OP,寻找标记的高亮线,并更改为所需的值,以满足您的需要。。。
 
  1. (defun c:norm ( / *error* adoc lst_layer func_restore-layers tab )
  2. (defun *error* (msg)
  3.    (func_restore-layers)
  4.    (vla-endundomark adoc)
  5.    (princ msg)
  6.    (princ)
  7.    ) ;_ end of defun
  8. (defun func_restore-layers ()
  9.    (foreach item lst_layer
  10.      (vla-put-lock (car item) (cdr (assoc "lock" (cdr item))))
  11.      (vl-catch-all-apply
  12.        '(lambda ()
  13.           (vla-put-freeze
  14.             (car item)
  15.             (cdr (assoc "freeze" (cdr item)))
  16.             ) ;_ end of vla-put-freeze
  17.           ) ;_ end of lambda
  18.        ) ;_ end of vl-catch-all-apply
  19.      ) ;_ end of foreach
  20.    ) ;_ end of defun
  21. (vl-load-com)
  22. (vla-startundomark
  23.    (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
  24.    ) ;_ end of vla-startundomark
  25. (if (and (not (vl-catch-all-error-p
  26.                  (setq selset
  27.                         (vl-catch-all-apply
  28.                           (function
  29.                             (lambda ()
  30.                               (ssget '((0 . "INSERT")))
  31.                               ) ;_ end of lambda
  32.                             ) ;_ end of function
  33.                           ) ;_ end of vl-catch-all-apply
  34.                        ) ;_ end of setq
  35.                  ) ;_ end of vl-catch-all-error-p
  36.                ) ;_ end of not
  37.           selset
  38.           ) ;_ end of and
  39.    (progn
  40.      (vlax-for item (vla-get-layers adoc)
  41.        (setq
  42.          lst_layer (cons (list item
  43.                                (cons "lock" (vla-get-lock item))
  44.                                (cons "freeze" (vla-get-freeze item))
  45.                                ) ;_ end of list
  46.                          lst_layer
  47.                          ) ;_ end of cons
  48.          ) ;_ end of setq
  49.        (vla-put-lock item :vlax-false)
  50.        (vl-catch-all-apply
  51.          '(lambda () (vla-put-freeze item :vlax-false))
  52.          ) ;_ end of vl-catch-all-apply
  53.        ) ;_ end of vlax-for
  54.      (foreach blk_def
  55.               (mapcar
  56.                 (function
  57.                   (lambda (x)
  58.                     (vla-item (vla-get-blocks adoc) x)
  59.                     ) ;_ end of lambda
  60.                   ) ;_ end of function
  61.                 ((lambda (/ res)
  62.                    (foreach item (mapcar
  63.                                    (function
  64.                                      (lambda (x)
  65.                                        (vla-get-name
  66.                                          (vlax-ename->vla-object x)
  67.                                          ) ;_ end of vla-get-name
  68.                                        ) ;_ end of lambda
  69.                                      ) ;_ end of function
  70.                                    ((lambda (/ item)
  71.                                       (repeat (setq tab  nil
  72.                                                     item (sslength selset)
  73.                                                     ) ;_ end setq
  74.                                         (setq
  75.                                           tab
  76.                                            (cons
  77.                                              (ssname selset
  78.                                                      (setq item (1- item))
  79.                                                      ) ;_ end of ssname
  80.                                              tab
  81.                                              ) ;_ end of cons
  82.                                           ) ;_ end of setq
  83.                                         ) ;_ end of repeat
  84.                                       tab
  85.                                       ) ;_ end of lambda
  86.                                     )
  87.                                    ) ;_ end of mapcar
  88.                      (if (not (member item res))
  89.                        (setq res (cons item res))
  90.                        ) ;_ end of if
  91.                      ) ;_ end of foreach
  92.                    (reverse res)
  93.                    ) ;_ end of lambda
  94.                  )
  95.                 ) ;_ end of mapcar
  96.        (vlax-for ent blk_def
  97.          (vla-put-layer ent "0")
  98.          (vla-put-color ent 0)
  99.          (vla-put-lineweight ent aclnwtbyblock)
  100.          (vla-put-linetype ent "byblock")
  101.          ) ;_ end of vlax-for
  102.        ) ;_ end of foreach
  103.      (func_restore-layers)
  104.      (vla-regen adoc acallviewports)
  105.      ) ;_ end of progn
  106.    ) ;_ end of if
  107. (vla-endundomark adoc)
  108. (foreach bl tab
  109.    (vla-put-layer (vlax-ename->vla-object bl) "0") [highlight];;; => Change "0" to desired Layer name ;;;[/highlight]
  110. )
  111. (princ)
  112. ) ;_ end of defun

 
M、 R。
回复

使用道具 举报

34

主题

174

帖子

60

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
257
发表于 2022-7-6 00:22:27 | 显示全部楼层
 
我真的同意
回复

使用道具 举报

3

主题

15

帖子

12

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 00:28:42 | 显示全部楼层
嗯,我想改变块和嵌套块内所有对象的层,以及块也进入同一层。。。
 
 
我还没有测试!!!将在12小时后进行测试。。。。
回复

使用道具 举报

3

主题

15

帖子

12

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 00:39:26 | 显示全部楼层
嘿m8谢谢。。。这就是我想要修改的。。。谢谢但是这个lisp没有考虑嵌套块。。。我希望嵌套lisp更改为“0”层或所需层。。。。。
 
是的,你真的很厉害。。。。你得到了我真正想要的,但没有做到。。。这真是太棒了。。。请将要更改的行添加到嵌套块。。。。
 
对不起,我的英语(我不是用这种语言写的)
 
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-11 00:11 , Processed in 0.665635 second(s), 72 queries .

© 2020-2025 乐筑天下

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