Black reformat (postprocessing files)
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
# ***************************************************************************/
|
||||
|
||||
|
||||
'''
|
||||
"""
|
||||
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.
|
||||
@@ -40,7 +40,7 @@ assumed. The user should carefully examine the resulting gcode!
|
||||
|
||||
Read the Path Workbench documentation to know how to create Path objects
|
||||
from GCode.
|
||||
'''
|
||||
"""
|
||||
|
||||
import os
|
||||
import FreeCAD
|
||||
@@ -61,7 +61,7 @@ if LEVEL == PathLog.Level.DEBUG:
|
||||
|
||||
|
||||
# to distinguish python built-in open function from the one declared below
|
||||
if open.__module__ in ['__builtin__', 'io']:
|
||||
if open.__module__ in ["__builtin__", "io"]:
|
||||
pythonopen = open
|
||||
|
||||
|
||||
@@ -90,10 +90,10 @@ def insert(filename, docname):
|
||||
gfile.close()
|
||||
|
||||
# Regular expression to match tool changes in the format 'M6 Tn'
|
||||
p = re.compile('[mM]+?\s?0?6\s?T\d*\s')
|
||||
p = re.compile("[mM]+?\s?0?6\s?T\d*\s")
|
||||
|
||||
# split the gcode on tool changes
|
||||
paths = re.split('([mM]+?\s?0?6\s?T\d*\s)', gcode)
|
||||
paths = re.split("([mM]+?\s?0?6\s?T\d*\s)", gcode)
|
||||
|
||||
# iterate the gcode sections and add customs for each
|
||||
toolnumber = 0
|
||||
@@ -103,7 +103,7 @@ def insert(filename, docname):
|
||||
# if the section is a tool change, extract the tool number
|
||||
m = p.match(path)
|
||||
if m:
|
||||
toolnumber = int(m.group().split('T')[-1])
|
||||
toolnumber = int(m.group().split("T")[-1])
|
||||
continue
|
||||
|
||||
# Parse the gcode and throw away any empty lists
|
||||
@@ -113,10 +113,15 @@ def insert(filename, docname):
|
||||
|
||||
# Create a custom and viewobject
|
||||
obj = PathCustom.Create("Custom")
|
||||
res = PathOpGui.CommandResources('Custom', PathCustom.Create,
|
||||
PathCustomGui.TaskPanelOpPage,
|
||||
'Path_Custom',
|
||||
QtCore.QT_TRANSLATE_NOOP('Path_Custom', 'Custom'), '', '')
|
||||
res = PathOpGui.CommandResources(
|
||||
"Custom",
|
||||
PathCustom.Create,
|
||||
PathCustomGui.TaskPanelOpPage,
|
||||
"Path_Custom",
|
||||
QtCore.QT_TRANSLATE_NOOP("Path_Custom", "Custom"),
|
||||
"",
|
||||
"",
|
||||
)
|
||||
obj.ViewObject.Proxy = PathOpGui.ViewProvider(obj.ViewObject, res)
|
||||
obj.ViewObject.Proxy.setDeleteObjectsOnReject(False)
|
||||
|
||||
@@ -127,16 +132,24 @@ def insert(filename, docname):
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
|
||||
|
||||
|
||||
def parse(inputstring):
|
||||
"parse(inputstring): returns a parsed output string"
|
||||
|
||||
supported = ['G0', 'G00',
|
||||
'G1', 'G01',
|
||||
'G2', 'G02',
|
||||
'G3', 'G03',
|
||||
'G81', 'G82', 'G83',
|
||||
'G90', 'G91']
|
||||
supported = [
|
||||
"G0",
|
||||
"G00",
|
||||
"G1",
|
||||
"G01",
|
||||
"G2",
|
||||
"G02",
|
||||
"G3",
|
||||
"G03",
|
||||
"G81",
|
||||
"G82",
|
||||
"G83",
|
||||
"G90",
|
||||
"G91",
|
||||
]
|
||||
|
||||
axis = ["X", "Y", "Z", "A", "B", "C", "U", "V", "W"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user