Category: Qtvcp
Material movement won't work in `machine_test`; it is just a simple configuration for testing purposes. In my configuration, I write the following code in the custom qtdragon handler file:
if (hal.component_exists("vismach")) == False:
c = hal.component("vismach")
c.newpin("mat_X_min", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("mat_Y_min", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("mat_Z_min", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("mat_X", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("mat_Y", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("mat_Z", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("mat_X_max", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("mat_Y_max", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("mat_Z_max", hal.HAL_FLOAT, hal.HAL_IN)
c.newpin("hide-chuck", hal.HAL_BIT, hal.HAL_IN)
c.newpin("hide-konik", hal.HAL_BIT, hal.HAL_IN)
c.newpin("os3", hal.HAL_BIT, hal.HAL_IN)
c.ready()
STATUS.connect('graphics-gcode-properties',lambda w, d: update_gcode_properties(d))
def update_gcode_properties(props):
if props != None:
print ("update update_gcode")
s = linuxcnc.stat()
s.poll()
print("MatPoz :", s.g5x_offset[2])
property_names = {
'x': "X bounds:",'x_zero_rxy':'X @ Zero Rotation:',
'y': "Y bounds:",'y_zero_rxy':'Y @ Zero Rotation:',
'z': "Z bounds:",'z_zero_rxy':'Z @ Zero Rotation:',
'a': "A bounds:", 'b': "B bounds:",
}
#print (props)
X_poz_min = float((props.get('x_zero_rxy').split())[0])
Y_poz_min = float((props.get('y_zero_rxy').split())[0])
Z_poz_min = float((props.get('z_zero_rxy').split())[0])
X_poz = float((props.get('x_zero_rxy').split())[4])
Y_poz = float((props.get('y_zero_rxy').split())[4])
Z_poz = float((props.get('z_zero_rxy').split())[4])
X_poz_max = float((props.get('x_zero_rxy').split())[2])
Y_poz_max = float((props.get('y_zero_rxy').split())[2])
# Z_poz_max = float((props.get('z_zero_rxy').split())[2])
Z_poz_max = (s.g5x_offset[2])
# G20 -> G21
if props.get('gcode_units') == 'in':
X_poz_min *= 25.4
X_poz *= 25.4
X_poz_max *= 25.4
Y_poz_min *= 25.4
Y_poz *= 25.4
Y_poz_max *= 25.4
Z_poz_min *= 25.4
Z_poz *= 25.4
print ("mat_X_min =", X_poz_min," mat_X_max =", X_poz_max," mat_X =", X_poz)
print ("mat_Y_min =", Y_poz_min," mat_Y_max =", Y_poz_max," mat_Y =", Y_poz)
print ("mat_Z_min =", Z_poz_min," mat_Z_max =", Z_poz_max," mat_Z =", Z_poz)
hal.set_p("vismach.mat_X_min", X_poz_min)
hal.set_p("vismach.mat_X", X_poz)
hal.set_p("vismach.mat_X_max", X_poz_max)
hal.set_p("vismach.mat_Y_min", Y_poz_min)
hal.set_p("vismach.mat_Y", Y_poz)
hal.set_p("vismach.mat_Y_max", Y_poz_max)
hal.set_p("vismach.mat_Z_min", Z_poz_min)
hal.set_p("vismach.mat_Z", Z_poz )
hal.set_p("vismach.mat_Z_max", Z_poz_max)
So, it writes the dimension positions to the HAL pins, and then, in the handler file, it reads the material dimensions from those pins (just like in that commented-out section that constructs the material).
This function is located in the qtdragon handler file because it isn't called within the vismach file itself when launching vismach in a standalone window; however, this approach allows for launching a second (or subsequent) vismach window without issues (e.g., to test with different parameters).
I'm constantly making tweaks—like saving the machined material to an STL file.
If you have any interesting ideas, let me know.