Welcome to AUGI.
Based on what I was able to glean from your OP, give this a try:
Basically, this starts a Command Reactor that will determine which space you are in by evaluating the CVPORT sysvar, and sets both the INSUNITS, and MODEMACRO sysvar accordingly. I've preemptively used the Meters & Millimeters values here, but others can simply change the red values to suite their own work as needed.
Code:
(vl-load-com)
;;;--------------------------------------------------------------------;
;;; Start reactor function:
(defun UnitsReactor:Start ()
;; Command reactors
(or *UnitsReactors_Command*
(setq *UnitsReactors_Command*
(vlr-command-reactor
nil
'(
(:vlr-commandCancelled . UnitsReactor:SetUnitsOnCommand)
(:vlr-commandEnded . UnitsReactor:SetUnitsOnCommand)
(:vlr-commandFailed . UnitsReactor:SetUnitsOnCommand)
(:vlr-commandWillStart . UnitsReactor:SetUnitsOnCommand)
)
)
)
)
(prompt "\nUnits reactor started. ")
(princ)
)
;;;--------------------------------------------------------------------;
;;; UnitsReactor:SetMessage function:
(defun UnitsReactor:SetMessage (insunits / msg modemacro i)
(setq msg
(strcat
"INSUNITS: "
(cond
((= 0 insunits) "Unitless")
((= 1 insunits) "Inches")
((= 2 insunits) "Feet")
((= 3 insunits) "Miles")
((= 4 insunits) "Millimeters")
((= 5 insunits) "Centimeters")
((= 6 insunits) "Meters")
((= 7 insunits) "Kilometers")
((= 8 insunits) "Microinches")
((= 9 insunits) "Mils")
((= 10 insunits) "Yards")
((= 11 insunits) "Angstroms")
((= 12 insunits) "Nanometers")
((= 13 insunits) "Microns")
((= 14 insunits) "Decimeters")
((= 15 insunits) "Dekameters")
((= 16 insunits) "Hectometers")
((= 17 insunits) "Gigameters")
((= 18 insunits) "Astronomical Units")
((= 19 insunits) "Light Years")
((= 20 insunits) "Parsecs")
)
" | "
)
)
(if
(setq i
(vl-string-search "| " (setq modemacro (getvar 'modemacro)))
)
(setvar 'modemacro
(vl-string-subst msg (substr modemacro 1 (+ 2 i)) modemacro)
)
(setvar 'modemacro (strcat msg modemacro))
)
(princ)
)
;;;--------------------------------------------------------------------;
;;; UnitsReactor:SetUnitsOnCommand callback function:
(defun UnitsReactor:SetUnitsOnCommand (rea cmd)
(UnitsReactor:SetMessage
(setvar 'insunits
(if (= 1 (getvar 'cvport))
4 ; paper, millimeters
6 ; model, or active viewport, meters
)
)
)
)
;;;--------------------------------------------------------------------;
;;; Stop reactor function:
(defun c:StopUnitsReactor ()
;; Command reactors
(if *UnitsReactors_Command*
(progn
(vlr-remove *UnitsReactors_Command*)
(setq *UnitsReactors_Command* nil)
)
)
(setvar 'modemacro "")
(prompt "\n** Units reactor stopped. **")
(princ)
)
;;;--------------------------------------------------------------------;
;;; autorun at load:
(UnitsReactor:Start)
Cheers