03-25-2022, 12:01 PM
I understand but I would like to standardize this via a postprocessor.
This is what I got so far.
def RunCode(self, code, is_function_call=False):
"""Adds code or a function call"""
# add counter attribute if this is the first call to RunCode
if not hasattr(self, "M51_counter"):
self.M51_counter = 0
if "M_RunCode(50)" in code:
# filtering M50
self.addline("\n")
self.addline("laser on")
self.addline("\n")
return
elif "M_RunCode(51)" in code:
# ignore the first M51 call
if self.M51_counter > 0:
# In program events, we'll be filtering M50 by M_RunCode by default
self.addline("\n")
self.addline("laser off")
self.addline("\n")
return
# always increase the counter, even if it was 0
self.M51_counter += 1
return
if "M_RunCode(30)" in code:
self.addline("")
return
(Indentations might be displayed not correctly)
As you can see this "uses" the M-Codes for adding new lines.
我只是想添加行不”劫持ing" the M-Codes at the very end of the ouput file.
This is what I got so far.
def RunCode(self, code, is_function_call=False):
"""Adds code or a function call"""
# add counter attribute if this is the first call to RunCode
if not hasattr(self, "M51_counter"):
self.M51_counter = 0
if "M_RunCode(50)" in code:
# filtering M50
self.addline("\n")
self.addline("laser on")
self.addline("\n")
return
elif "M_RunCode(51)" in code:
# ignore the first M51 call
if self.M51_counter > 0:
# In program events, we'll be filtering M50 by M_RunCode by default
self.addline("\n")
self.addline("laser off")
self.addline("\n")
return
# always increase the counter, even if it was 0
self.M51_counter += 1
return
if "M_RunCode(30)" in code:
self.addline("")
return
(Indentations might be displayed not correctly)
As you can see this "uses" the M-Codes for adding new lines.
我只是想添加行不”劫持ing" the M-Codes at the very end of the ouput file.