(命令“取消定义”“行”)
然后键入:
(defun c:LINE()(命令“layer”set“pause”“.LINE”))
这符合你的要求吗?
如果要返回原始行命令,请在命令行中键入以下内容:
(命令“redefine”“line”) 在他的两条相似的线索(同一个问题)之间,他应该有很多选择。现在由他来决定什么最适合他的需要,除非他另有要求。 实际上,这不是“最佳”解决方案。问题是,不建议在反应堆回调中使用输入函数。原因是,当命令启动时,反应堆点火,但随后暂停,直到用户提供一些输入。一般来说,它“不应该”出现问题,但可能会引起诸如脚本或来自其他lisp函数的命令调用之类的问题。
不幸的是,由于OP希望能够从列表中选择层,因此无法回避这个问题。
我不认为我建议使用命令反应器是“最佳”解决方案(至少在本线程中不是这样)。
我的意思是我的发言相当字面;为了澄清。。。
根据调用的特定命令,您指定的三个反应器具有相同的回调函数(在我的代码中)。
我将全局变量与:vlr CommandWillStart一起使用,在将当前层更改为调用命令的预定义层(即_XREF command=XREF layer)之前存储当前层。一旦命令完成(或取消等),我的回调将恢复起始层(通过全局var),并将所述var重置为nil。
编辑:
此外,可以*潜在*使用ActiveX向用户提供选项列表,选择层,然后相应地设置层。。。都没有发出第二个命令,不是吗?
问题是有多少层可以用作选项,当然不是一个大的层列表的全部。也许定制DCL可以解决这个问题?(我认为这太过分了,但仍然如此)。 这是我用的
;;--------------------=={ 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 set to be enabled upon loading the program ;;
;;it can furthermore be toggled on and off using by typing;;
;;'LD' at the command line. ;;
;;------------------------------------------------------------;;
;;Author: Lee McDonnell, 2010 ;;
;; ;;
;;Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
;;Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
;;------------------------------------------------------------;;
(defun c:LD nil (LM:LayerDirector T))
(defun LM:LayerDirector ( msg )
(vl-load-com)
;; © Lee Mac 2010
(setq *LayerData*
'(
("*TEXT" "TEXT" 2)
("*DIM*,*QLEADER""DIMENSIONS" 2)
("*VPORT*" "DEFPOINTS"7)
("*EXECUTETOOL" "4" 4)
)
)
(
(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 msg
(if (and react (vlr-added-p react))
(princ "\n<< Layer Director Enabled >>" )
(princ "\n<< Layer Director Disabled >>")
)
)
)
"LayerDirector"
'LayerDirectorSet
'LayerDirectorReset
)
(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)
)
)
)
)
(defun LayerDirectorSet ( reactor arguments / layerdetails layer )
(vl-load-com)
;; © Lee Mac 2010
(if
(and
(setq layerdetails
(vl-some
(function
(lambda ( x )
(if (wcmatch (strcase (car arguments)) (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 arguments )
(vl-load-com)
;; © Lee Mac 2010
(if
(and (not (wcmatch (strcase (car arguments)) "*UNDO")) *oldlayer*
(tblsearch "LAYER" *oldlayer*)
(zerop
(logand 1
(cdr
(assoc 70
(tblsearch "LAYER" *oldlayer*)
)
)
)
)
)
(progn
(setvar 'CLAYER *oldlayer*)
(setq *oldlayer* nil)
)
)
(princ)
)
(princ)
(LM:LayerDirector nil) 对不起,我不是想影射你的方法是错误的,也不是试图劝阻你(或任何其他人)使用这种特殊的方法。我只是想展示一些地方,在这种情况下,它可能会导致事情破裂。我的建议是,如果脚本/lisp/其他自定义项发出了命令,那么这个反应器不应该启动,否则它会有效地引入一个额外的提示(最好)或一个对话框(最坏),这会导致错误。一、 e.它至少需要检查CMDACTIVE sysvar的位代码4(脚本)和64(ObjectARX),尽管从AutoLisp检查时未设置位代码32(AutoLisp)。这就是我对多层选择的想法有点怀疑的地方。因此,您需要检查其他内容,或者需要通过其他Lisp/VBA/whatever手动禁用反应堆。
如果每个命令只有一个层,那么就不会有这个问题。就像李的密码一样,我也怀疑你的密码。我指的不是从反应堆回调中发出命令(这是由于可能的无限循环而产生的另一个麻烦),正如李的代码所示,你不需要这样做,也不应该这样做。
您还可以打开一个非模式对话框(DotNet或OpenDCL)来显示这些层选项。因此,该命令可以继续,而无需任何其他用户/脚本/lisp输入。在这种情况下,最好让对话框的操作修改任何新实体,而不是简单地设置当前层。我能看出人们怎么会真的这么做。
实现这一点的唯一其他方法是重新定义可疑命令,正如其他方法所示。尽管这样,您肯定需要其他lisp/script来使用。调用这些命令时使用前缀。您需要重新定义要检查的每个命令-可以通过单步遍历列表,生成未定义调用并将其定义为字符串,然后使用read&eval函数从该字符串重新定义命令来实现自动化。
实际上我应该说,没有“最佳”解决方案。他们都有问题,你需要决定哪些问题可以忍受。 我在很多方面都同意你的观点,有一天,我可能会消化掉你分享的所有知识。
命令电抗器适用于特定序列(给定命令总是设置指定的层电流等)。
相反,我可能会考虑编写一组命令(或宏?)表示将绘制线的图层,例如:
4
键盘快捷键是我的首选方法,但为了完整起见,我加入了“全名”功能。
**注-不包括错误检查。
编辑:
也许还有更基本的东西:
5 这可能是“最安全”的方法。为了更容易完成:
现在,只需修改每个命令的前2个列表,不幸的是,没有为命令名进行通配符匹配。它为每个命令层组合创建一个命令。
页:
1
[2]