[PATH] make -custom- op compliant. Improve gcode_pre importer

This commit is contained in:
sliptonic
2020-06-04 15:26:55 -05:00
parent 4786d62839
commit 0fa628928d
11 changed files with 332 additions and 116 deletions

View File

@@ -25,7 +25,8 @@
'''
This is an example preprocessor file for the Path workbench. Its aim is to
open a gcode file, parse its contents, and create the appropriate objects
in FreeCAD.
in FreeCAD. This preprocessor will not add imported gcode to an existing
job. For a more useful preprocessor, look at the gcode_pre.py file
Read the Path Workbench documentation to know how to create Path objects
from GCode.
@@ -76,8 +77,8 @@ def parse(inputstring):
PathLog.track(inputstring)
# split the input by line
lines = inputstring.split("\n")
output = [] #""
lastcommand = None
output = []
lastcommand = None
for lin in lines:
# remove any leftover trailing and preceding spaces
@@ -98,8 +99,7 @@ def parse(inputstring):
continue
if lin[0].upper() in ["G", "M"]:
# found a G or M command: we store it
#output += lin + "\n"
output.append(Path.Command(str(lin))) # + "\n"
output.append(Path.Command(str(lin)))
last = lin[0].upper()
for c in lin[1:]:
if not c.isdigit():
@@ -109,7 +109,7 @@ def parse(inputstring):
lastcommand = last
elif lastcommand:
# no G or M command: we repeat the last one
output.append(Path.Command(str(lastcommand + " " + lin))) # + "\n"
output.append(Path.Command(str(lastcommand + " " + lin)))
print("done preprocessing.")
return output