Good morning
I found this macro on the net (JIM TAYLOR) for the center of the piece and it works well (for me) I tried to modify it to insert the parameters, I also used " #5= question......" but it doesn't work (don't laugh !!!!), if possible I would like to use a screen to enter the data, since it is not in my skills (I understand very little about programming) is there any soul who can help me?
;Set the monitor variables to zero
#1=0
#2=0
#3=0
#4=0
#5=180 (X-rh)
#6=0 (X-lh)
#7=200 (Y-top)
#8=0 (Y-bot)
#9=0 (good x-ctr)
#10=0 (good Y-ctr)
#17=0 (Z-ref)
#18=4 (edge clearances)
#11=[[#5-#6]/2] (nominal X-value of block center)
#12=[[#7-#8]/2] (nominal Y-value of block center)
#13=-3.5 (some Z-value below the block surface)
#14=3 (probe tip radius)
#15=[#5-#6] (nominal width X-dir)
#16=[#7-#8] (nominal height Y-dir)
;move to nominal block center
G0 X#11 Y#12 (move to nominal block center)
G31 Z-50 f50 (probe Z-ref)
G0 Z[#2002+2] (move above block)
#17=#2002
;probe +X side of block
g0 X[#11+#15/2+#14+#18] (move past +X-edge)
g0 Z[#13+#17] (descend below surface)
G31 X[#11 - #15] (probe +X side of block)
#5=[#2000-#14] (RH edge)
g0 Z[#17+2]
;move to nominal block center
G0 X#11 Y#12 (move to nominal block center)
;probe -X side of block
g0 X[#11-#15/2-#14-#18] (move past -X-edge)
g0 Z[#13+#17] (descend below surface)
G31 X[#11 + #15] (probe -X side of hole)
#6=[#2000+#14] (LH edge)
#9=[[#5 + #6] / 2.0] (good X-block center)
g0 z[#17+2]
#1=[#5-#6] (+RH edge + -LH edge - +tool dia = Xwidth)
;################################################
;move to nominal block center
G0 X#9 Y#12 (back to center of block)
;probe +Y side of block
g0 Y[#12+#16/2+#14+#18] (move past +Y-edge)
g0 Z[#13+#17] (descend below surface)
G31 Y[#12 - #16]
#7=[#2001-#14] (Top edge)
g0 Z[#17+2]
;move to nominal block center
G0 X#9 Y#12 (back to center of block)
;probe +Y side of block
g0 Y[#12-#16/2-#14-#18] (move past -Y-edge)
g0 Z[#13+#17] (descend below surface)
G31 Y[#12 + #16] (probe -Y side of block)
#8=[#2001+#14] (Bot edge)
#10=[[#7 + #8] / 2.0] (good Y-value block center)
g0 Z[#17+2]
#2=[#7-#8] (Top edge - Bot edge - tool dia = Yheight)
g0 x#9 y#10 (go to XYctr)
M30