层控制器故障
我用的是李的图层控制器,非常棒。我已经在阿卡多克装了子弹。lsp。问题是,对于我们系统中的一些人来说,当他们打开一个图形时,反应堆被启用,而对于其他人来说,它被禁用。有什么办法吗?;;-------------------=={ 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 62colour) (cons 700) ) ) ) )(princ) (LM:LayerDirector) (princ)
谢谢 嗨,伍德曼,
首先,请记住,代码末尾有一个函数调用:
(LM:LayerDirector),程序加载后立即启动。听起来在这之后有一个单独的函数调用,它将禁用反应器(因为反应器被编码为切换)。
另一方面:
主持人:代码格式是怎么回事?是代码本身还是我们又被黑客攻击了?
李 我已经检查了代码,代码末尾似乎没有额外的调用。你能创建一个打开和关闭例程而不是切换吗。我仍然有一些用户的问题?
谢谢
李麦克 我也有同样的问题…^^ Arin9916,
我把它整理好了。我刚刚注释掉了要在关闭时切换的行,以便它始终加载。代码如下。如果要创建关闭开关,只需注释掉红色高亮显示行下方的行“(vlr add react)”,然后删除;从行“;(vlr remove react)”。应该做到这一点。您还需要分别重命名它们。叫一个LD-ON和另一个LD-OFF之类的。
;;-------------------=={ 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" "CCC_LAYOUT_Text" 7)
("*DIM*,*QLEADER*,*MLEADER" "CCC_LAYOUT_Dimensions" 7)
("*VPORT*" "CCC_SHEET_LAYOUT_Viewport" 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 62colour)
(cons 700)
)
)
)
)
(princ) (LM:LayerDirector) (princ)
小心点!如果出于任何原因,LSP被加载了多次,或者在这种情况下,您多次键入LD。。。每次为发出的每个命令启动反应堆时,都会让反应堆运行一次。所以你的ACad会变得非常慢!
李,我通常更喜欢给我创建的反应堆设置一些数据:这样我可以遍历所有反应堆,看看它是否已经打开,然后再打开!此外,如果在某个地方出现这种重复的反应堆东西,则更容易移除错误的反应堆。(编辑:对不起,我看到你真的这么做了)。
在这种情况下,你不能简单地通过所有反应器,关闭所有匹配的数据,然后只重新创建一个版本吗?或者关闭除一个之外的所有功能。如果你不遵循其中一个,你将不得不坚持使用开关。 这种修改可能会导致它添加另一个反应堆,即使已经有一个反应堆,而且用户将无法关闭它。
这更好:
;;-------------------=={ 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 'LDON' or 'LDOFF' at the;;
;;command line. ;;
;;------------------------------------------------------------;;
;;Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
(defun c:LDONnil (LM:LayerDirector T))
(defun c:LDOFF nil (LM:LayerDirector nil))
(defun LM:LayerDirector ( on / react )
(setq *LayerData*
'(
("*TEXT" "TEXT" 2)
("*DIM*,*QLEADER""DIMENSIONS" 2)
("*VPORT*" "DEFPOINTS"7)
)
)
(setq react
(vl-some
(function
(lambda ( reactor )
(if (eq "LayerDirector" (vlr-data reactor))
reactor
)
)
)
(cdar (vlr-reactors :vlr-command-reactor))
)
)
(cond
( on
(if react
(if (vlr-added-p react)
(princ "\n--> Layer Director Already Running.")
(vlr-add react)
)
(progn
(vlr-command-reactor "LayerDirector"
(list
(cons :vlr-commandWillStart 'LayerDirectorSet)
(cons :vlr-commandEnded 'LayerDirectorReset)
(cons :vlr-commandCancelled 'LayerDirectorReset)
)
)
(princ "\n--> Layer Director Enabled.")
)
)
)
( react
(vlr-remove react)
(princ "\n--> Layer Director Disabled.")
)
( (princ "\n--> Layer Director Not Running.") )
)
(princ)
)
(defun LayerDirectorSet ( reactor params / layerdetails layer )
(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 )
(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 62colour)
(cons 700)
)
)
)
)
(princ) (vl-load-com) (LM:LayerDirector T) (princ) 好啊谢谢你的代码LeeMac。 感谢您查看代码Irneb,以及您的想法
页:
[1]