can it be turned off at will
i think i have a lisp that works with a reactor
problem is I can't turn the reactor off anymore like i use too.
it might also need another lisp which is called autolay 3.0
and i know that it needs a vlr-manager.fas and
another sub lisp to get things moving arch_vlr_command.lsp and capslock.lsp
i could have sworn i use to be able to turn off the reactor i know it says type autolay to toggle but it doesnt work.
oh and if you press shift while typing in autocad it will let you type in lowercase.
;|=====================================================================
Capslock.lsp complete with notes and all
For Autocad 2000x
Written by: Eric Schneider, Reno, NV
3/27/2002
cadking@aol.com
=======================================================================
This program automatically toggles the 'capslock' whenever a *text command
is encountered. Or it's supposed to anyway!
=======================================================================
This program requires VLR-Manager.fas and doslib2k.arx to be in the AutoCAD
support path for "capslock" to work (both supplied in the CapsLock.zip).
=======================================================================
Anyone is welcome to use modify this program or hack it to bits as long
as Eric Schneider, or any other names aforementioned, are not held
responsible for anything whatsoever and shall not be the subject of
vulgarities. Just leave the credits in it. Deal? Cool! Enjoy the freedom
of not having to toggle the 'capslock' key as much!
=======================================================================|;
;;;load VLISP extensions
(vl-load-com);initialize VLISP extensions
;;;load the reactor manager
(if (findfile "VLR-Manager")(member nil (atoms-family 1 '("vlr-manager" "vlr-family" "vlr-object" "vlr-object-p" "vlr-syntax")))
(load "VLR-Manager")
)
;toggles autolay on and off
(defun c:capslock (/ funcs file)
(setq funcs '(c:capslock cl:capslock))
(if
(and
(not (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\AutoLay" "CapsLock"));is AutoLay turned on or off in the registry?
(member nil (atoms-family 1 (mapcar 'vl-princ-to-string funcs)));are any AutoLay subfunctions not loaded
(or
(member (setq file "doslib2k.arx")(arx))
(if (setq file (findfile file))
(arxload file)
)
)
(setq file (findfile "CapsLock.lsp"))
)
(progn
(vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\AutoLay" "CapsLock" "T");set registry for AutoLay enabled
(load file);load "CapsLock.lsp"
)
(progn
(vl-registry-delete "HKEY_CURRENT_USER\\SOFTWARE\\AutoLay" "CapsLock");set registry for AutoLay disabled
(mapcar
'(lambda (x)(set x nil));set all CapsLock subroutines to nil
(vl-remove 'c:capslock funcs);except for the ones needed to re-enable AutoLay
)
(vlr-manager '(VLR-DWG-reactor nil '((:VLR-beginClose . cl:disable))) 1);remove reactor
(vlr-manager '(VLR-Command-reactor nil '((:VLR-commandWillStart . capslock)(:VLR-commandEnded . capslock)(:VLR-commandCancelled . capslock))) 1);remove reactor
(princ "\nUnloaded CapsLock.lsp")
)
)
(princ)
)
;;;=======================================================================
(if (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\AutoLay" "CapsLock");if CapsLokc is enabled in the registry, continue loading
(progn
(defun cl:capslock (reactor info / cmd crn);main body, togles 'capslock' key
(setq cmd (strcase (car info))
crn (vlr-current-reaction-name)
)
(if
(or
(wcmatch cmd "*LEADER,*QLEADER,*MTEXT,*TEXT,*DDEDIT,*ATTEDIT")
(and
(wcmatch cmd "DIM,DIMLINEAR,DIMALIGNED,DIMORDINATE,DIMRADIUS,DIMDIAMETER,DIMANGULAR,DIMBASELINE,DIMCONTINUE,QDIM,LEADER,QLEADER,MTEXT,TEXT,DDEDIT")
(= (vlax-variant-value (vla-getvariable *adocobj* "dimaso")) 0)
)
)
(cond
( (member crn '(:VLR-commandEnded :VLR-commandCancelled))
(dos_capslock)
)
( (= crn ':VLR-commandWillStart )
(dos_capslock T)
)
)
)
)
;;;======================================================================
;;;disables commandEnded reactor to avoid errors when using "new" and "open"
;;;in SDI mode. The error is merely annoying and only appears at the command
;;;line as "error: no function definition: capslock" when opening or creating
;;;a new drawing. The cause of the error is commandEnded reactor present form
;;;last dwg but LISP has not yet loaded the called function in a new or opened
;;;dwg. Furthermore, the reactor cannot be removed because it has already been
;;;activated and is waiting for the command to end. Therefore, the reactor must
;;;be rendered non-functional by changing its call to the LISP command "LIST".
(defun cl:disable (reactor info / tdat)
(if
(= (vlax-variant-value (vla-getvariable (vlr-data reactor) "sdi")) 1);in SDI mode?
(vlr-reaction-set
(car (vlr-object '(VLR-Command-reactor nil '((:VLR-commandWillStart . cl:capslock)(:VLR-commandEnded . cl:capslock)(:VLR-commandCancelled . cl:capslock)))))
:VLR-commandEnded
'list
)
);end if
);end defun
;;;======================================================================
;;;Here's where we construct the reactors to do all this cool stuff
(vlr-manager '(VLR-DWG-reactor (vla-get-activedocument (vlax-get-acad-object)) '((:VLR-beginClose . cl:disable))) 3)
(vlr-manager '(VLR-Command-reactor nil '((:VLR-commandWillStart . cl:capslock)(:VLR-commandEnded . cl:capslock)(:VLR-commandCancelled . cl:capslock))) 3)
;;;======================================================================
;;;get rid of old reactor if present. The reactor will be present, because in
;;;SDI mode, it's associated namespace is not destroyed, but has the new drawing
;;;loaded into it. At the time this file is loaded, this reactor is either not
;;;present or has been rendered useless (in SDI mode) at the closing of the last
;;;dwg and is excess loaded code bulk and should be removed. The VLR-MANAGER
;;;provides an easy means of doing this.
(vlr-manager '(VLR-Command-reactor nil '((:VLR-commandWillStart . cl:capslock)(:VLR-commandEnded . list)(:VLR-commandCancelled . cl:capslock))) 1)
;;;======================================================================
(princ "\nLoaded CapsLock.lsp\n")
);end progn
(princ "\nLoaded CapsLock.lsp. Type \"capslock\" to enable.")
);end if
(princ)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; This original Copyrighted routine has been modified...
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;controlled by arch_subroutines.lsp file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;|
Also, be aware that returning to the previous layer with OldLayer
where OldLayer is a symbol for the layer that we are going to return to,
is often cause for an error; AutoCAD rejects that very often.
A safe way to return to the previous layer is this:
(if (/= (getvar "clayer") OldLayer)
(vla-setvariable (vla-get-activedocument (vlax-get-acad-object))
"clayer" OldLayer)
)
Alfredo Medina
alfmedina@hotmail.com
|;
(defun ARCH_OldLayer ()
(if (/= (getvar "clayer") OldLayer)
(vla-setvariable (vla-get-activedocument (vlax-get-acad-object)) "clayer" OldLayer)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; VLR_COMMAND.lsp courtesy Peter Jamtgaard 2003
;;; Vlr Command is a function that will switch the active layer in a drawing.
;;; The reactor checks the command that is starting and if it recognizes it
;;; it will switch to a specified layer. If the layer doesn't exist it will
;;; create it with the color, linetype, and plottable setting provided.
;;; To load and run this program add the lines (load "vlr_command")(c:vlr_command)
;;; to your acaddoc.lsp or another autoloading lisp routine.
(defun VLR_COMMAND-IT ()
(vl-load-com)
(vlr-command-reactor nil '((:vlr-commandWillStart . startCommand)))
(vlr-command-reactor nil '((:vlr-commandEnded . endCommand)))
(vlr-command-reactor nil '((:vlr-commandCancelled . cancelCommand)))
(vlr-editor-reactor nil '((:vlr-commandwillstart . ARCH:COM1)))
)
(princ "\n*** ------ Layer Reactor Activated. ------ ***")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:COM1 (CALL CALLBACK / COMLAYLST)
;;; List of corrusponding commands layers color linetype plottable
(setq COMLAYLST
(list (list "DIMANGULAR" "dim" 4 "continuous" :vlax-true)
(list "DIMBASELINE" "dim" 4 "continuous" :vlax-true)
(list "DIMCENTER" "dim" 4 "continuous" :vlax-true)
(list "DIMCONTINUE" "dim" 4 "continuous" :vlax-true)
(list "DIMDIAMETER" "dim" 4 "continuous" :vlax-true)
(list "DIMLINEAR" "dim" 4 "continuous" :vlax-true)
(list "DIMORDINATE" "dim" 4 "continuous" :vlax-true)
(list "DIMRADIUS" "dim" 4 "continuous" :vlax-true)
(list "QDIM" "dim" 4 "continuous" :vlax-true)
(list "DIMALIGNED" "dim" 4 "continuous" :vlax-true)
(list "LEADER" "dim" 4 "continuous" :vlax-true)
(list "QLEADER" "dim" 4 "continuous" :vlax-true)
(list "DTEXT" "text" 4 "continuous" :vlax-true)
(list "MTEXT" "text" 4 "continuous" :vlax-true)
;;(list "TEXT" "text" 4 "continuous" :vlax-true)
(list "POINT" "X-PNTS" 7 "continuous" :vlax-true)
(list "XREF" "XREF" 7 "continuous" :vlax-true)
)
)
(foreach
N COMLAYLST
(if (= (strcase (car CALLBACK)) (strcase (car N)))
(progn
(make_layers
(cadr N)
(caddr N)
(cadddr N)
(car (cddddr N))
)
(setq n1 n)
(vla-put-activelayer
(vla-get-activedocument
(vlax-get-acad-object)
)
(vlax-ename->vla-object
(tblobjname "LAYER" (cadr N))
)
)
)
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Make layers using activeX
(defun MAKE_LAYERS (LAY_NAM COLOR LTYPE PLOTL / LAYOBJ LAYSOBJ LTYPESOBJ)
(setq CDWGOBJ (vla-get-activedocument
(vlax-get-acad-object)
)
LAYSOBJ (vla-get-layers CDWGOBJ)
)
(if (not (tblobjname "layer" LAY_NAM))
(vl-catch-all-error-p
(vl-catch-all-apply 'vla-add (list LAYSOBJ LAY_NAM))
)
)
(setq LAYOBJ (vla-item LAYSOBJ LAY_NAM))
(if (not (tblobjname "ltype" LTYPE))
(progn
(setq LTYPESOBJ (vla-get-linetypes CDWGOBJ))
(vla-load LTYPESOBJ LTYPE (findfile "acad.lin"))
(vlax-release-object LTYPESOBJ)
)
)
(vla-put-layeron LAYOBJ :vlax-true)
(if (/= (strcase (vla-get-name LAYOBJ)) (strcase (getvar "clayer")))
(vla-put-freeze LAYOBJ :vlax-false)
)
(vla-put-lock LAYOBJ :vlax-false)
(vla-put-color LAYOBJ COLOR)
(vla-put-linetype LAYOBJ LTYPE)
(vla-put-plottable LAYOBJ PLOTL)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;Kenny Ramage @ afralisp.com
(defun startCommand (calling-reactor
startcommandInfo
/
thecommandstart
)
(setq OldLayer (getvar "CLAYER"))
(setq OldLayern OldLayer)
;;(vlr-editor-reactor nil '((:vlr-commandwillstart . ARCH:COM1)))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun endCommand (calling-reactor
endcommandInfo
/
thecommandend
)
(setq thecommandend (nth 0 endcommandInfo))
(cond
((= thecommandend "DIMANGULAR") (ARCH_OldLayer))
((= thecommandend "DIMBASELINE") (ARCH_OldLayer))
((= thecommandend "DIMCENTER") (ARCH_OldLayer))
((= thecommandend "DIMCONTINUE") (ARCH_OldLayer))
((= thecommandend "DIMDIAMETER") (ARCH_OldLayer))
((= thecommandend "DIMLINEAR") (ARCH_OldLayer))
((= thecommandend "DIMORDINATE") (ARCH_OldLayer))
((= thecommandend "DIMRADIUS") (ARCH_OldLayer))
((= thecommandend "QDIM") (ARCH_OldLayer))
((= thecommandend "DIMALIGNED") (ARCH_OldLayer))
((= thecommandend "LEADER") (ARCH_OldLayer))
((= thecommandend "QLEADER") (ARCH_OldLayer))
((= thecommandend "DTEXT") (ARCH_OldLayer))
((= thecommandend "MTEXT") (ARCH_OldLayer))
;;((= thecommandend "TEXT") (ARCH_OldLayer))
((= thecommandend "POINT") (ARCH_OldLayer))
((= thecommandend "XREF") (ARCH_OldLayer))
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun cancelCommand (calling-reactor
cancelcommandInfo
/
thecommandcancel
)
(setq thecommandcancel (nth 0 cancelcommandInfo))
(cond
((= thecommandcancel "DIMANGULAR") (ARCH_OldLayer))
((= thecommandcancel "DIMBASELINE") (ARCH_OldLayer))
((= thecommandcancel "DIMCENTER") (ARCH_OldLayer))
((= thecommandcancel "DIMCONTINUE") (ARCH_OldLayer))
((= thecommandcancel "DIMDIAMETER") (ARCH_OldLayer))
((= thecommandcancel "DIMLINEAR") (ARCH_OldLayer))
((= thecommandcancel "DIMORDINATE") (ARCH_OldLayer))
((= thecommandcancel "DIMRADIUS") (ARCH_OldLayer))
((= thecommandcancel "QDIM") (ARCH_OldLayer))
((= thecommandend "DIMALIGNED") (ARCH_OldLayer))
((= thecommandcancel "LEADER") (ARCH_OldLayer))
((= thecommandcancel "QLEADER") (ARCH_OldLayer))
((= thecommandcancel "DTEXT") (ARCH_OldLayer))
((= thecommandcancel "MTEXT") (ARCH_OldLayer))
;;((= thecommandcancel "TEXT") (ARCH_OldLayer))
((= thecommandcancel "POINT") (ARCH_OldLayer))
((= thecommandcancel "XREF") (ARCH_OldLayer))
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(VLR_COMMAND-IT)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ)