(vl-load-com)

(defun DimReactor:Start ()
(or *DimReactor*
(setq *DimReactor*
(vlr-command-reactor
nil
'(
(:vlr-commandcancelled . DimReactor:CommandEnded)
(:vlr-commandended . DimReactor:CommandEnded)
(:vlr-commandfailed . DimReactor:CommandEnded)
(:vlr-commandwillstart . DimReactor:CommandWillStart)
)
)
)
)
(prompt "\nDimension reactor loaded. ")
(princ)
)

(defun DimReactor:CommandEnded (rea cmd)
(if
(and
*DimReactorLayer*
(wcmatch
(strcase (car cmd))
"DIMA*,DIMB*,DIMC*,DIMD*,DIMI*,DIMJ*,DIML*,DIMO*,DIMR*,DIMSP*,QDIM"
)
)
(progn
(setvar 'clayer *DimReactorLayer*)
(setq *DimReactorLayer* nil)
)
)
)

(defun DimReactor:CommandWillStart (rea cmd / layerName)
(if
(wcmatch
(strcase (car cmd))
"DIMA*,DIMB*,DIMC*,DIMD*,DIMI*,DIMJ*,DIML*,DIMO*,DIMR*,DIMSP*,QDIM"
)
(progn
(setq *DimReactorLayer* (getvar 'clayer))
(vla-add
(vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
(setq layerName "0-DIM")
)
(setvar 'clayer layerName)
)
)
)

(defun c:DimReactorStart ()
(DimReactor:Start)
)

(defun c:DimReactorStop ()
(if *DimReactor*
(progn
(vlr-remove *DimReactor*)
(setq *DimReactor* nil)
)
)
(prompt "\n** Dimension reactor stopped ** ")
(princ)
)

;; Uncomment next line to start automatically.
;;(DimReactor:Start)
(princ)

Advertisements