olá lacerda
este aqui é para achar o centro de peças e inserir no "G54", eu acho bastante util:
%DEF ORIGEM,-XHO,
(SK 1="G54",SK 2="G55",SK 3="G56",SK 4="G57",SK 5="CENTRO G54",SK 7="SAIDA")
N5 (WKEY)
(IF KEY EQ $FC00 GOTO N10)
(IF KEY EQ $FC01 GOTO N20)
(IF KEY EQ $FC02 GOTO N30)
(IF KEY EQ $FC03 GOTO N40)
(IF KEY EQ $FC04 GOTO N50)
(IF KEY EQ $FC06 SYSTEM ELSE GOTO N5)
;
N10 (SK 1="X",SK 2="Y",SK 3="Z",SK 4="B",SK 7="SAIDA")
N15 (WKEY)
(IF KEY EQ $FC00 GOTO N100)
(IF KEY EQ $FC01 GOTO N110)
(IF KEY EQ $FC02 GOTO N120)
(IF KEY EQ $FC03 GOTO N130)
(IF KEY EQ $FC06 SYSTEM ELSE GOTO N15)
;
N20 (SK 1="X",SK 2="Y",SK 3="Z",SK 4="B",SK 7="SAIDA")
N25 (WKEY)
(IF KEY EQ $FC00 GOTO N200)
(IF KEY EQ $FC01 GOTO N210)
(IF KEY EQ $FC02 GOTO N220)
(IF KEY EQ $FC03 GOTO N230)
(IF KEY EQ $FC06 SYSTEM ELSE GOTO N25)
;
N30 (SK 1="X",SK 2="Y",SK 3="Z",SK 4="B",SK 7="SAIDA")
N35 (WKEY)
(IF KEY EQ $FC00 GOTO N300)
(IF KEY EQ $FC01 GOTO N310)
(IF KEY EQ $FC02 GOTO N320)
(IF KEY EQ $FC03 GOTO N330)
(IF KEY EQ $FC06 SYSTEM ELSE GOTO N35)
;
N40 (SK 1="X",SK 2="Y",SK 3="Z",SK 4="B",SK 7="SAIDA")
N45 (WKEY)
(IF KEY EQ $FC00 GOTO N400)
(IF KEY EQ $FC01 GOTO N410)
(IF KEY EQ $FC02 GOTO N420)
(IF KEY EQ $FC03 GOTO N430)
(IF KEY EQ $FC06 SYSTEM ELSE GOTO N45)
;
N50 (SK 1="X =>",SK 2="<= X",SK 3="Y =>",SK 4="<= Y",SK 5="Z =>",SK 6="< =Z",SK 7="SAIDA")
N55 (WKEY)
(IF KEY EQ $FC00 GOTO N500)
(IF KEY EQ $FC01 GOTO N501)
(IF KEY EQ $FC02 GOTO N502)
(IF KEY EQ $FC02 GOTO N503)
(IF KEY EQ $FC02 GOTO N504)
(IF KEY EQ $FC02 GOTO N505)
(IF KEY EQ $FC06 SYSTEM ELSE GOTO N55)
;
N100 (ORGX54=POSX)
G54
(GOTO N10)
N110 (ORGY54=POSY)
G54
(GOTO N10)
N120 (ORGZ54=POSZ)
G54
(GOTO N10)
N130 (ORGB54=POSB)
G54
(GOTO N10)
;
N200 (ORGX55=POSX)
G55
(GOTO N20)
N210 (ORGY55=POSY)
G55
(GOTO N20)
N220 (ORGZ55=POSZ)
G55
(GOTO N20)
N230 (ORGB55=POSB)
G55
(GOTO N20)
;
N300 (ORGX56=POSX)
G56
(GOTO N30)
N310 (ORGY56=POSY)
G56
(GOTO N30)
N320 (ORGZ56=POSZ)
G56
(GOTO N30)
N330 (ORGB56=POSB)
G56
(GOTO N30)
;
N400 (ORGX57=POSX)
G57
(GOTO N40)
N410 (ORGY57=POSY)
G57
(GOTO N40)
N420 (ORGZ57=POSZ)
G57
(GOTO N40)
N430 (ORGB57=POSB)
G57
(GOTO N40)
;
;*************************
;*************************
N500 (P100=POSX)
(GOTO N50)
N501 (ORGX54=(POSX+P100)/2)
G54
(GOTO N50)
;
N502 (P101=POSY)
(GOTO N50)
N503 (ORGY54=(POSY+P101)/2)
G54
(GOTO N50)
;
N504 (P102=POSZ)
(GOTO N50)
N505 (ORGZ54=(POSZ+P102)/2)
G54
(GOTO N50)
;
N800;(FIM)