乐筑天下

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

[编程交流] 层控制器故障

[复制链接]

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 09:25:54 | 显示全部楼层 |阅读模式
我用的是李的图层控制器,非常棒。我已经在阿卡多克装了子弹。lsp。问题是,对于我们系统中的一些人来说,当他们打开一个图形时,反应堆被启用,而对于其他人来说,它被禁用。有什么办法吗?
  1. ;;-------------------=={ Layer Director }==-------------------;; ;;                                                            ;; ;;  Uses a command reactor to automatically set the layer     ;; ;;  upon the user invoking certain commands.                  ;; ;;                                                            ;; ;;  Layer settings are stored in the list at the top of the   ;; ;;  program. The first entry in the list is the command on    ;; ;;  which the reactor will trigger, it may use wildcards.     ;; ;;  The second entry is the designated layer for the command  ;; ;;  entered, this layer will be created if non-existent.      ;; ;;  The third entry is the layer colour that will be used if  ;; ;;  the layer is to be created in the drawing.                ;; ;;                                                            ;; ;;  The Reactor is enabled upon loading the program - it may  ;; ;;  be toggled on and off by typing 'LD' at the command line. ;; ;;------------------------------------------------------------;; ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;; ;;------------------------------------------------------------;;  (defun c:LD nil (LM:LayerDirector))  (defun LM:LayerDirector nil (vl-load-com)    (setq *LayerData*    '(      ("*TEXT"           "TEXT"       2)      ("*DIM*,*QLEADER"  "DIMENSIONS" 2)      ("*VPORT*"         "DEFPOINTS"  7)     )   )          (     (lambda ( data callback1 callback2 / react )       (if         (setq react           (vl-some             (function               (lambda ( reactor )                 (if (eq data (vlr-data reactor))                   reactor                 )               )             )             (cdar (vlr-reactors :vlr-command-reactor))           )         )         (if (vlr-added-p react)           (vlr-remove react)           (vlr-add react)         )         (setq react           (vlr-command-reactor data             (list               (cons :vlr-commandWillStart callback1)               (cons :vlr-commandEnded     callback2)               (cons :vlr-commandCancelled callback2)             )           )         )       )              (if (and react (vlr-added-p react))         (princ "\n<< Layer Director Enabled >>" )         (princ "\n<< Layer Director Disabled >>")       )     )      "LayerDirector"     'LayerDirectorSet     'LayerDirectorReset   )   (princ) )  (defun LayerDirectorSet ( reactor params / layerdetails layer ) (vl-load-com)   (if     (and       (setq params (strcase (car params)) layerdetails         (vl-some           (function             (lambda ( x )               (if (wcmatch params (car x)) (cdr x))             )           )           *LayerData*         )       )       (LM:MakeLayer (setq layer (car layerdetails)) (cadr layerdetails))       (zerop         (logand 1           (cdr             (assoc 70               (tblsearch "LAYER" layer)             )           )         )       )     )     (progn       (setq *oldlayer* (getvar 'CLAYER))             (setvar 'CLAYER layer)     )   )   (princ) )  (defun LayerDirectorReset ( reactor params ) (vl-load-com)   (if     (and (not (wcmatch (strcase (car params)) "*UNDO")) *oldlayer* (tblsearch "LAYER" *oldlayer*)       (zerop         (logand 1           (cdr             (assoc 70               (tblsearch "LAYER" *oldlayer*)             )           )         )       )     )     (progn       (setvar 'CLAYER *oldlayer*)       (setq *oldlayer* nil)     )   )     (princ) )  (defun LM:MakeLayer ( name colour )   (or (tblsearch "LAYER" name)     (entmakex       (list         (cons 0   "LAYER")         (cons 100 "AcDbSymbolTableRecord")         (cons 100 "AcDbLayerTableRecord")         (cons 2   name)         (cons 62  colour)         (cons 70  0)       )     )   ) )  (princ) (LM:LayerDirector) (princ)

 
谢谢
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:36:31 | 显示全部楼层
嗨,伍德曼,
 
首先,请记住,代码末尾有一个函数调用:
 
  1. (LM:LayerDirector)
,程序加载后立即启动。听起来在这之后有一个单独的函数调用,它将禁用反应器(因为反应器被编码为切换)。
 
另一方面:
 
主持人:代码格式是怎么回事?是代码本身还是我们又被黑客攻击了?
 
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 09:42:21 | 显示全部楼层
我已经检查了代码,代码末尾似乎没有额外的调用。你能创建一个打开和关闭例程而不是切换吗。我仍然有一些用户的问题?
 
谢谢
李麦克
回复

使用道具 举报

10

主题

38

帖子

28

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
50
发表于 2022-7-6 09:50:08 | 显示全部楼层
我也有同样的问题…^^
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 10:01:57 | 显示全部楼层
Arin9916,
我把它整理好了。我刚刚注释掉了要在关闭时切换的行,以便它始终加载。代码如下。如果要创建关闭开关,只需注释掉红色高亮显示行下方的行“(vlr add react)”,然后删除;从行“;(vlr remove react)”。应该做到这一点。您还需要分别重命名它们。叫一个LD-ON和另一个LD-OFF之类的。
 
 
  1. ;;-------------------=={ Layer Director }==-------------------;;
  2. ;;                                                            ;;
  3. ;;  Uses a command reactor to automatically set the layer     ;;
  4. ;;  upon the user invoking certain commands.                  ;;
  5. ;;                                                            ;;
  6. ;;  Layer settings are stored in the list at the top of the   ;;
  7. ;;  program. The first entry in the list is the command on    ;;
  8. ;;  which the reactor will trigger, it may use wildcards.     ;;
  9. ;;  The second entry is the designated layer for the command  ;;
  10. ;;  entered, this layer will be created if non-existent.      ;;
  11. ;;  The third entry is the layer colour that will be used if  ;;
  12. ;;  the layer is to be created in the drawing.                ;;
  13. ;;                                                            ;;
  14. ;;  The Reactor is enabled upon loading the program - it may  ;;
  15. ;;  be toggled on and off by typing 'LD' at the command line. ;;
  16. ;;------------------------------------------------------------;;
  17. ;;  Author: Lee Mac, Copyright © 2011 - [url="http://www.lee-mac.com/"]www.lee-mac.com[/url]       ;;
  18. ;;------------------------------------------------------------;;
  19. (defun c:LD nil (LM:LayerDirector))
  20. (defun LM:LayerDirector nil (vl-load-com)
  21. (setq *LayerData*
  22.   '(
  23.     ("*TEXT" "CCC_LAYOUT_Text" 7)
  24.     ("*DIM*,*QLEADER*,*MLEADER" "CCC_LAYOUT_Dimensions" 7)
  25.     ("*VPORT*" "CCC_SHEET_LAYOUT_Viewport" 7)
  26.    )
  27. )      
  28. (
  29.    (lambda ( data callback1 callback2 / react )
  30.      (if
  31.        (setq react
  32.          (vl-some
  33.            (function
  34.              (lambda ( reactor )
  35.                (if (eq data (vlr-data reactor))
  36.                  reactor
  37.                )
  38.              )
  39.            )
  40.            (cdar (vlr-reactors :vlr-command-reactor))
  41.          )
  42.        )
  43.        (if (vlr-added-p react)
  44. [color=red]        ;(vlr-remove react)[/color]
  45.          (vlr-add react)
  46.        )
  47.        (setq react
  48.          (vlr-command-reactor data
  49.            (list
  50.              (cons :vlr-commandWillStart callback1)
  51.              (cons :vlr-commandEnded     callback2)
  52.              (cons :vlr-commandCancelled callback2)
  53.            )
  54.          )
  55.        )
  56.      )
  57.      (if (and react (vlr-added-p react))
  58.        (princ "\n<< Layer Director Enabled >>" )
  59.        (princ "\n<< Layer Director Disabled >>")
  60.      )
  61.    )
  62.    "LayerDirector"
  63.    'LayerDirectorSet
  64.    'LayerDirectorReset
  65. )
  66. (princ)
  67. )
  68. (defun LayerDirectorSet ( reactor params / layerdetails layer ) (vl-load-com)
  69. (if
  70.    (and
  71.      (setq params (strcase (car params)) layerdetails
  72.        (vl-some
  73.          (function
  74.            (lambda ( x )
  75.              (if (wcmatch params (car x)) (cdr x))
  76.            )
  77.          )
  78.          *LayerData*
  79.        )
  80.      )
  81.      (LM:MakeLayer (setq layer (car layerdetails)) (cadr layerdetails))
  82.      (zerop
  83.        (logand 1
  84.          (cdr
  85.            (assoc 70
  86.              (tblsearch "LAYER" layer)
  87.            )
  88.          )
  89.        )
  90.      )
  91.    )
  92.    (progn
  93.      (setq *oldlayer* (getvar 'CLAYER))      
  94.      (setvar 'CLAYER layer)
  95.    )
  96. )
  97. (princ)
  98. )
  99. (defun LayerDirectorReset ( reactor params ) (vl-load-com)
  100. (if
  101.    (and (not (wcmatch (strcase (car params)) "*UNDO")) *oldlayer* (tblsearch "LAYER" *oldlayer*)
  102.      (zerop
  103.        (logand 1
  104.          (cdr
  105.            (assoc 70
  106.              (tblsearch "LAYER" *oldlayer*)
  107.            )
  108.          )
  109.        )
  110.      )
  111.    )
  112.    (progn
  113.      (setvar 'CLAYER *oldlayer*)
  114.      (setq *oldlayer* nil)
  115.    )
  116. )  
  117. (princ)
  118. )
  119. (defun LM:MakeLayer ( name colour )
  120. (or (tblsearch "LAYER" name)
  121.    (entmakex
  122.      (list
  123.        (cons 0   "LAYER")
  124.        (cons 100 "AcDbSymbolTableRecord")
  125.        (cons 100 "AcDbLayerTableRecord")
  126.        (cons 2   name)
  127.        (cons 62  colour)
  128.        (cons 70  0)
  129.      )
  130.    )
  131. )
  132. )
  133. (princ) (LM:LayerDirector) (princ)
回复

使用道具 举报

11

主题

968

帖子

919

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2022-7-6 10:06:02 | 显示全部楼层
小心点!如果出于任何原因,LSP被加载了多次,或者在这种情况下,您多次键入LD。。。每次为发出的每个命令启动反应堆时,都会让反应堆运行一次。所以你的ACad会变得非常慢!
 
李,我通常更喜欢给我创建的反应堆设置一些数据:这样我可以遍历所有反应堆,看看它是否已经打开,然后再打开!此外,如果在某个地方出现这种重复的反应堆东西,则更容易移除错误的反应堆。(编辑:对不起,我看到你真的这么做了)。
 
在这种情况下,你不能简单地通过所有反应器,关闭所有匹配的数据,然后只重新创建一个版本吗?或者关闭除一个之外的所有功能。如果你不遵循其中一个,你将不得不坚持使用开关。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:16:38 | 显示全部楼层
这种修改可能会导致它添加另一个反应堆,即使已经有一个反应堆,而且用户将无法关闭它。
 
这更好:
 
  1. ;;-------------------=={ Layer Director }==-------------------;;
  2. ;;                                                            ;;
  3. ;;  Uses a command reactor to automatically set the layer     ;;
  4. ;;  upon the user invoking certain commands.                  ;;
  5. ;;                                                            ;;
  6. ;;  Layer settings are stored in the list at the top of the   ;;
  7. ;;  program. The first entry in the list is the command on    ;;
  8. ;;  which the reactor will trigger, it may use wildcards.     ;;
  9. ;;  The second entry is the designated layer for the command  ;;
  10. ;;  entered, this layer will be created if non-existent.      ;;
  11. ;;  The third entry is the layer colour that will be used if  ;;
  12. ;;  the layer is to be created in the drawing.                ;;
  13. ;;                                                            ;;
  14. ;;  The Reactor is enabled upon loading the program - it may  ;;
  15. ;;  be toggled on and off by typing 'LDON' or 'LDOFF' at the  ;;
  16. ;;  command line.                                             ;;
  17. ;;------------------------------------------------------------;;
  18. ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
  19. ;;------------------------------------------------------------;;
  20. (defun c:LDON  nil (LM:LayerDirector   T))
  21. (defun c:LDOFF nil (LM:LayerDirector nil))
  22. (defun LM:LayerDirector ( on / react )
  23. (setq *LayerData*
  24.   '(
  25.     ("*TEXT"           "TEXT"       2)
  26.     ("*DIM*,*QLEADER"  "DIMENSIONS" 2)
  27.     ("*VPORT*"         "DEFPOINTS"  7)
  28.    )
  29. )
  30. (setq react
  31.    (vl-some
  32.      (function
  33.        (lambda ( reactor )
  34.          (if (eq "LayerDirector" (vlr-data reactor))
  35.            reactor
  36.          )
  37.        )
  38.      )
  39.      (cdar (vlr-reactors :vlr-command-reactor))
  40.    )
  41. )
  42. (cond
  43.    ( on
  44.      (if react
  45.        (if (vlr-added-p react)
  46.          (princ "\n--> Layer Director Already Running.")
  47.          (vlr-add react)
  48.        )
  49.        (progn
  50.          (vlr-command-reactor "LayerDirector"
  51.            (list
  52.              (cons :vlr-commandWillStart 'LayerDirectorSet)
  53.              (cons :vlr-commandEnded     'LayerDirectorReset)
  54.              (cons :vlr-commandCancelled 'LayerDirectorReset)
  55.            )
  56.          )
  57.          (princ "\n--> Layer Director Enabled.")
  58.        )
  59.      )
  60.    )
  61.    ( react
  62.      (vlr-remove react)
  63.      (princ "\n--> Layer Director Disabled.")
  64.    )
  65.    ( (princ "\n--> Layer Director Not Running.") )
  66. )
  67. (princ)
  68. )
  69. (defun LayerDirectorSet ( reactor params / layerdetails layer )
  70. (if
  71.    (and
  72.      (setq params (strcase (car params)) layerdetails
  73.        (vl-some
  74.          (function
  75.            (lambda ( x )
  76.              (if (wcmatch params (car x)) (cdr x))
  77.            )
  78.          )
  79.          *LayerData*
  80.        )
  81.      )
  82.      (LM:MakeLayer (setq layer (car layerdetails)) (cadr layerdetails))
  83.      (zerop
  84.        (logand 1
  85.          (cdr
  86.            (assoc 70
  87.              (tblsearch "LAYER" layer)
  88.            )
  89.          )
  90.        )
  91.      )
  92.    )
  93.    (progn
  94.      (setq *oldlayer* (getvar 'CLAYER))      
  95.      (setvar 'CLAYER layer)
  96.    )
  97. )
  98. (princ)
  99. )
  100. (defun LayerDirectorReset ( reactor params )
  101. (if
  102.    (and (not (wcmatch (strcase (car params)) "*UNDO")) *oldlayer* (tblsearch "LAYER" *oldlayer*)
  103.      (zerop
  104.        (logand 1
  105.          (cdr
  106.            (assoc 70
  107.              (tblsearch "LAYER" *oldlayer*)
  108.            )
  109.          )
  110.        )
  111.      )
  112.    )
  113.    (progn
  114.      (setvar 'CLAYER *oldlayer*)
  115.      (setq *oldlayer* nil)
  116.    )
  117. )  
  118. (princ)
  119. )
  120. (defun LM:MakeLayer ( name colour )
  121. (or (tblsearch "LAYER" name)
  122.    (entmakex
  123.      (list
  124.        (cons 0   "LAYER")
  125.        (cons 100 "AcDbSymbolTableRecord")
  126.        (cons 100 "AcDbLayerTableRecord")
  127.        (cons 2   name)
  128.        (cons 62  colour)
  129.        (cons 70  0)
  130.      )
  131.    )
  132. )
  133. )
  134. (princ) (vl-load-com) (LM:LayerDirector T) (princ)
回复

使用道具 举报

145

主题

590

帖子

446

银币

中流砥柱

Rank: 25

铜币
725
发表于 2022-7-6 10:22:20 | 显示全部楼层
好啊谢谢你的代码LeeMac。
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 10:31:49 | 显示全部楼层
感谢您查看代码Irneb,以及您的想法
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 03:18 , Processed in 0.562194 second(s), 70 queries .

© 2020-2025 乐筑天下

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