Thanks for the guidance. I implemented the following code and it seems to work. The logic is that the laser has to be 0.375" of less (relative) above the surface. AND the laser engraver tool number (

must be selected. And the motion input (triggered by a M62 P21 or M64 P21) must be true.
Currently I program z=0 as the top of the work surface. This code won't work if I program z=0 as the spoilboard or somewhere else. I guess I could use another M code to set a laser safety height or something. We'll see how this works first.
-Jim
# inhibit laser engraver when at unsafe height (relative)
addf comp.0 servo-thread
setp comp.0.in1 0.375 # okay to have engraver on below this (relative) z height
setp comp.0.hyst 0.005 # hysteresis
net engraver-height-current comp.0.in0 <= halui.axis.z.pos-relative
# engraver tool (T8) must be the active tool and height must be safe
addf conv-u32-float.0 servo-thread
net tool_number_u32 <= halui.tool.number => conv-u32-float.0.in
net tool_number_float <= conv-u32-float.0.out
addf comp.1 servo-thread
setp comp.1.in0 8 # engraver tool number
setp comp.1.hyst 0.0001 # floating point is never equal
net tool_number_float => comp.1.in1
addf and2.3 servo-thread
net engrave-safe-height <= comp.0.out => and2.3.in0
net engrave-safe-selected <= motion.digital-out-21 => and2.3.in1
net engrave-signal <= and2.3.out
# make sure comp.1.equal and engrave_signal are both true, if so we turn on optimat_o_laser_engraver_pwm
addf and2.4 servo-thread
net engrave-signal => and2.4.in0
net engrave-tool-match => comp.1.equal => and2.4.in1
net engrave_pwm <= optimat_o_laser_engraver_pwm <= and2.4.out