模板新手的优点,
使用模板(以及已经创建的vport层),您仍然需要记住在绘制端口之前切换到vport层,然后在绘制其他对象之前切换回。这显然需要更多的时间,并且LISP发布更快,因为如果已经创建了vport层,它不会复制vport层。
解决这个问题的另一种方法是使用反应堆——我最近(在ASMI和其他人的帮助下)了解了一些。
下面是一个可以使用模板的反应器。
- ; Layer Director
- (vl-load-com)
- (vlr-command-reactor
- nil '((:vlr-commandWillstart . startCommand))
- ) ; end command reactor
- (vlr-command-reactor
- nil '((:vlr-commandEnded . endcommand))
- ) ; end command reactor
- (vlr-command-reactor
- nil '((:vlr-commandCancelled . cancelCommand))
- ) ; end command reactor
- (defun startCommand (calling-reactor startcommandInfo / thecommandstart)
- (setq oldlay (getvar "clayer"))
- (setq thecommandstart (nth 0 startcommandInfo))
- (cond
- ((= thecommandstart "+VPORTS")
- (setvar "clayer" "VPORT")
- ) ; end condition
- ) ; end cond
- (princ)
- ) ; end startcommand
- (defun endCommand (calling-reactor endcommandInfo / thecommandend)
- (setq thecommandend (nth 0 endcommandInfo))
- (cond
- ((= thecommandend "+VPORTS")
- (setvar "clayer" oldlay)
- ) ; end condition
- ) ; end cond
- (princ)
- ) ; end endCommand
- (defun cancelCommand (calling-reactor cancelcommandInfo / thecommandcancel)
- (setq thecommandcancel (nth 0 cancelcommandInfo))
- (cond
- ((= thecommandcancel "+VPORTS")
- (setvar "clayer" oldlay)
- ) ; end condition
- ) ; end cond
- (princ)
- ) ; end cancelCommand
|