Code:
pretract #End of tool path, toolchange
sav_absinc = absinc$ ( save mode )
absinc$ = one ( force mastercam into inremental mode)
sav_coolant = coolant$ ( save coolant status )
coolant$ = zero ( force Coolant OFF )
# if nextop$ = 1003, #Uncomment this line to leave coolant on until eof unless
[ # explicitely turned off through a canned text edit
if all_cool_off,
[
#all coolant off with a single off code here
if coolant_on, pbld, n$, sall_cool_off, e$
coolant_on = zero
]
else,
[
local_int = zero
coolantx = zero
while local_int < 20 & coolant_on > 0,
[
coolantx = and(2^local_int, coolant_on)
local_int = local_int + one
if coolantx > zero,
[
coolantx = local_int
pbld, n$, scoolantx, e$
]
coolantx = zero
]
coolant_on = zero
]
]
#cc_pos is reset in the toolchange here
cc_pos$ = zero ( force cutter comp OFF )
gcode$ = zero ( force Rapid mode )
#pbld, n$, sccomp, *sm05, psub_end_mny, e$ ( stop spindle )
pbld, n$, sccomp, "M9", psub_end_mny, e$ (Coolant OFF )
pbld, n$, *sgcode, sgabsinc, *sg28ref, "Z0.", "M19", e$ ( Retract to machine Z origin, stop & orientate the spindle )
if nextop$ = 1003 | tlchg_home, ( is this the last operation ??..... skip bracketted section if NO )
[
pbld, n$, *sg28ref, "Y0.", e$ ( retract to machine Y origin )
absinc$ = zero ( force mastercam into absolute mode )
pbld, n$, *sgcode, sgabsinc, protretinc, e$ ( force output of Rapid, Absolute, run the rotary return postblock )
]
absinc$ = sav_absinc ( set mastercam back to original mode before this postblock)
coolant$ = sav_coolant ( set back to original coolant setting )
I also suggest that you alter your toolchange program to include a G90 somewhere in the cycle, you could also incude a G94 ( Feed units per minute ) and a G80 ( cancel canned cycles) to make it a lot safer.