Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Append Lines to Code

#5
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.


Messages In This Thread
Append Lines to Code - byHerMer- 03-04-2022, 08:49 AM
RE: Append Lines to Code - byAlbert- 03-04-2022, 10:54 AM
RE: Append Lines to Code - byHerMer- 03-24-2022, 10:49 AM
RE: Append Lines to Code - byJeremy- 03-24-2022, 06:05 PM
RE: Append Lines to Code - byHerMer- 03-25-2022, 12:01 PM
RE: Append Lines to Code - byJeremy- 03-25-2022, 12:12 PM
RE: Append Lines to Code - byHerMer- 03-25-2022, 12:22 PM
RE: Append Lines to Code - byJeremy- 03-25-2022, 06:18 PM



Users browsing this thread:
1 Guest(s)