乐筑天下

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

[编程交流] 解锁所有层

[复制链接]

14

主题

74

帖子

60

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-5 16:19:46 | 显示全部楼层 |阅读模式
你好
我想知道是否有人知道一个lisp来解锁所有层。
谢谢
马可
回复

使用道具 举报

10

主题

8258

帖子

8335

银币

初来乍到

Rank: 1

铜币
31
发表于 2022-7-5 16:24:09 | 显示全部楼层
寻找,你就会发现。因此,在右上角的高级搜索框的原因。
 
http://www.cadtutor.net/forum/showthread.php?47611-解锁所有层
回复

举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 16:26:38 | 显示全部楼层
你好
 
不需要lisp,Autocad已经支持它。
 
命令:layulk
 
当做
 
塔瓦特
回复

举报

2

主题

182

帖子

180

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:29:27 | 显示全部楼层
为什么不需要通过lisp解锁层?如果您的程序必须绘制一些东西,并且层被锁定,该怎么办?
 
这是一个快速编写的程序,可以解锁图形中的所有层(这只是一个快速演示)。
  1. ( (lambda (/ layer)
  2.    ;;
  3.    ;; (ex) Unlock all layers in drawing using Visual Lisp.
  4.    ;;
  5.    ;; By: Se7en
  6.    ;; 07.28.10 08:11:00 AM
  7.    ;;
  8.    ;; Licence:
  9.    ;;
  10.    ;;  Copyright (c)2010-2011 John Kaul
  11.    ;;  All rights reserved.
  12.    ;;
  13.    ;;  Redistribution and use in source and binary forms, with or without
  14.    ;;  modification, are permitted provided that the following conditions
  15.    ;;  are met:
  16.    ;;
  17.    ;;   1. Redistributions of source code must retain the above copyright
  18.    ;;      notice, this list of conditions and the following disclaimer.
  19.    ;;   2. Redistributions in binary form must reproduce the above copyright
  20.    ;;      notice, this list of conditions and the following disclaimer in
  21.    ;;      the documentation and/or other materials provided with the
  22.    ;;      distribution.
  23.    ;;
  24.    ;;  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25.    ;;  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26.    ;;  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  27.    ;;  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  28.    ;;  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  29.    ;;  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  30.    ;;  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  31.    ;;  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  32.    ;;  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  33.    ;;  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  34.    ;;  THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  35.    ;;  DAMAGE.   
  36.    ;;
  37.    (vlax-for
  38.        layer
  39.    (vla-get-layers
  40.      (vla-get-activedocument
  41.        (vlax-get-acad-object)))
  42.        (if (vlax-get-property layer 'Lock)
  43.              (vlax-put-property layer 'Lock :vlax-false)))) )
回复

举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-5 16:34:14 | 显示全部楼层
在代码中,使用Se7en的方式,只需知道您也可以从命令行执行此操作。
 
如。
  1. Command: LA
  2. -LAYER
  3. Current layer:  "ALAN"
  4. Enter an option
  5. [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck
  6. /Unlock/stAte/Description/rEconcile]: U
  7. Enter name list of layer(s) to unlock or <select objects>: *
  8. Enter an option
  9. [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck
  10. /Unlock/stAte/Description/rEconcile]:
回复

举报

2

主题

182

帖子

180

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:38:35 | 显示全部楼层
这是另一种Visual Lisp方法。
  1. ( (lambda ( / )
  2.    ;;
  3.    ;;
  4.    ;; (ex) Unlock all layers in drawing using Visual Lisp.
  5.    ;;
  6.    ;; By: Se7en
  7.    ;; 07.28.10 08:30:00 AM
  8.    ;;
  9.    ;; Licence:
  10.    ;;
  11.    ;;  Copyright (c)2010-2011 John Kaul
  12.    ;;  All rights reserved.
  13.    ;;
  14.    ;;  Redistribution and use in source and binary forms, with or without
  15.    ;;  modification, are permitted provided that the following conditions
  16.    ;;  are met:
  17.    ;;
  18.    ;;   1. Redistributions of source code must retain the above copyright
  19.    ;;      notice, this list of conditions and the following disclaimer.
  20.    ;;   2. Redistributions in binary form must reproduce the above copyright
  21.    ;;      notice, this list of conditions and the following disclaimer in
  22.    ;;      the documentation and/or other materials provided with the
  23.    ;;      distribution.
  24.    ;;
  25.    ;;  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26.    ;;  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27.    ;;  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  28.    ;;  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  29.    ;;  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  30.    ;;  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  31.    ;;  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  32.    ;;  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  33.    ;;  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  34.    ;;  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  35.    ;;  THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  36.    ;;  DAMAGE.   
  37.    ;;
  38. (vlax-map-collection
  39.    (vla-get-layers (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))
  40.    '(lambda ( layer )
  41.            (if (vlax-get-property layer 'Lock)
  42.             (vlax-put-property layer 'Lock :vlax-true))))) )

 
这里有一些更酷的东西只使用自动Lisp。我使用大量变量创建了它,这样你可以更好地遵循这个过程。
 
  1. ( (lambda ( layername / layer lsylst props off freeze lock )
  2.    ;;
  3.    ;; (ex) Toggle layer's settings in drawing using Auto Lisp.
  4.    ;;
  5.    ;; By: Se7en
  6.    ;; 07.28.10 08:30:00 AM
  7.    ;;
  8.    ;; NOTES:
  9.    ;; 70 - Standard flags (bit-coded values):
  10.    ;; 1  = Layer is frozen; otherwise layer is thawed
  11.    ;; ...
  12.    ;; 4  = Layer is locked
  13.    ;; ...
  14.    ;; 62 - Color number (if negative, layer is off)
  15.    ;;
  16.    ;; Or if your feeling adventrous you can combine frozen and locked
  17.    ;; (1+4=5). something like...
  18.    ;;
  19.    ;; EXAMPLE:
  20.    ;; (setq laylst (entget (tblobjname "LAYER" "<YOUR LAYER NAME HERE>")))
  21.    ;; (entmod
  22.    ;;    (subst
  23.    ;;       (cons 70 (boole 6 (cdr (assoc 70 laylst)) 5))
  24.    ;;       (assoc 70 laylst)
  25.    ;;       laylst))
  26.    ;;
  27.    ;; Licence:
  28.    ;;
  29.    ;;  Copyright (c)2010-2011 John Kaul
  30.    ;;  All rights reserved.
  31.    ;;
  32.    ;;  Redistribution and use in source and binary forms, with or without
  33.    ;;  modification, are permitted provided that the following conditions
  34.    ;;  are met:
  35.    ;;
  36.    ;;   1. Redistributions of source code must retain the above copyright
  37.    ;;      notice, this list of conditions and the following disclaimer.
  38.    ;;   2. Redistributions in binary form must reproduce the above copyright
  39.    ;;      notice, this list of conditions and the following disclaimer in
  40.    ;;      the documentation and/or other materials provided with the
  41.    ;;      distribution.
  42.    ;;
  43.    ;;  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  44.    ;;  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  45.    ;;  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  46.    ;;  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  47.    ;;  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  48.    ;;  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  49.    ;;  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  50.    ;;  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  51.    ;;  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  52.    ;;  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  53.    ;;  THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  54.    ;;  DAMAGE.   
  55.    ;;
  56.    (setq layer (tblobjname "LAYER" layername))
  57.    (setq laylst (entget layer)
  58.          props (cdr (assoc 70 laylst))
  59.          off (cdr (assoc 62 laylst))
  60.          freeze 1
  61.          lock 4
  62.          )
  63.    (setq props (boole 6 props freeze))
  64.    (setq off (1+ (~ off)))
  65.    (setq props (boole 6 props lock))
  66.    (setq laylst (subst (cons 70 props) (assoc 70 laylst) laylst)
  67.          laylst (subst (cons 62 off) (assoc 62 laylst) laylst))
  68.    (entmod laylst)
  69.    )
  70. "0" ;; just for example. make this a named procedure to use in your library.
  71. )
回复

举报

2

主题

182

帖子

180

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:40:32 | 显示全部楼层
好的,我现在就停下来,你明白了。
回复

举报

2

主题

182

帖子

180

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:43:01 | 显示全部楼层
*我刚想起来为什么我不在这里发代码。。。愚蠢的GPL执照;我不希望我的代码在GPL下。
 
我将修复/添加我的标题到我上面发布的代码。
回复

举报

15

主题

687

帖子

169

银币

中流砥柱

Rank: 25

铜币
582
发表于 2022-7-5 16:46:42 | 显示全部楼层
你好
 
这里有一种使用defun-q在函数中存储未锁定层列表的方法,这样就可以通过调用相同的函数来重新锁定层。
 
使用
(gc:LayerUnLockAll T)解锁所有锁定的层,并将其存储在函数内的列表中
(gc:LayerUnLockAll nil)重新锁定先前存储在函数中的未锁定层。
 
  1. ;;; gc:LayerUnLockAll (gile)
  2. ;;; Unlock all layers or relock prevously locked layers
  3. ;;;
  4. ;;; Argument : T or nil
  5. ;;;
  6. ;;; Using :
  7. ;;; (gc:LayerUnLockAll T) unlock all locked layers
  8. ;;; (gc:LayerUnLockAll nil) relock previously unlocked layers
  9. (vl-load-com)
  10. (defun-q
  11. gc:layerunlockall
  12. (flag / lst lay)
  13. (setq lst nil)
  14. (if flag
  15.    (vlax-for l (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
  16.      (and (= (vla-get-Lock l) :vlax-true)
  17.       (setq lst (cons l lst))
  18.       (vla-put-Lock l :vlax-false)
  19.      )
  20.    )
  21.    (progn
  22.      (foreach n lst
  23.    (vl-catch-all-apply 'vla-put-Lock (list n :vlax-true))
  24.      )
  25.      (setq lst nil)
  26.    )
  27. )
  28. (setq    gc:layerunlockall
  29.     (cons (car gc:layerunlockall)
  30.           (cons (list 'setq 'lst (list 'quote lst))
  31.             (cddr gc:layerunlockall)
  32.           )
  33.     )
  34. )
  35. lst
  36. )
回复

举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 16:50:18 | 显示全部楼层
吉尔,
 
这不应该:
 
  1. (setq    layerunlockall
  2.     (cons (car layerunlockall)
  3.           (cons (list 'setq 'lst (list 'quote lst))
  4.             (cddr layerunlockall)
  5.           )
  6.     )
  7. )

 
be:
 
  1. (setq    [color=Red][b]gc:[/b][/color]layerunlockall
  2.     (cons (car [color=Red][b]gc:[/b][/color]layerunlockall)
  3.           (cons (list 'setq 'lst (list 'quote lst))
  4.             (cddr [b][color=Red]gc:[/color][/b]layerunlockall)
  5.           )
  6.     )
  7. )
回复

举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-15 03:15 , Processed in 1.990339 second(s), 72 queries .

© 2020-2025 乐筑天下

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