black reformat
This commit is contained in:
@@ -48,57 +48,109 @@ def translate(context, text, disambig=None):
|
||||
|
||||
|
||||
class ObjectProbing(PathOp.ObjectOp):
|
||||
'''Proxy object for Probing operation.'''
|
||||
"""Proxy object for Probing operation."""
|
||||
|
||||
def opFeatures(self, obj):
|
||||
'''opFeatures(obj) ... Probing works on the stock object.'''
|
||||
"""opFeatures(obj) ... Probing works on the stock object."""
|
||||
return PathOp.FeatureDepths | PathOp.FeatureHeights | PathOp.FeatureTool
|
||||
|
||||
def initOperation(self, obj):
|
||||
obj.addProperty("App::PropertyLength", "Xoffset", "Probe", QtCore.QT_TRANSLATE_NOOP("App::Property", "X offset between tool and probe"))
|
||||
obj.addProperty("App::PropertyLength", "Yoffset", "Probe", QtCore.QT_TRANSLATE_NOOP("App::Property", "Y offset between tool and probe"))
|
||||
obj.addProperty("App::PropertyInteger", "PointCountX", "Probe", QtCore.QT_TRANSLATE_NOOP("App::Property", "Number of points to probe in X direction"))
|
||||
obj.addProperty("App::PropertyInteger", "PointCountY", "Probe", QtCore.QT_TRANSLATE_NOOP("App::Property", "Number of points to probe in Y direction"))
|
||||
obj.addProperty("App::PropertyFile", "OutputFileName", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The output location for the probe data to be written"))
|
||||
obj.addProperty(
|
||||
"App::PropertyLength",
|
||||
"Xoffset",
|
||||
"Probe",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
"App::Property", "X offset between tool and probe"
|
||||
),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyLength",
|
||||
"Yoffset",
|
||||
"Probe",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
"App::Property", "Y offset between tool and probe"
|
||||
),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyInteger",
|
||||
"PointCountX",
|
||||
"Probe",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
"App::Property", "Number of points to probe in X direction"
|
||||
),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyInteger",
|
||||
"PointCountY",
|
||||
"Probe",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
"App::Property", "Number of points to probe in Y direction"
|
||||
),
|
||||
)
|
||||
obj.addProperty(
|
||||
"App::PropertyFile",
|
||||
"OutputFileName",
|
||||
"Path",
|
||||
QtCore.QT_TRANSLATE_NOOP(
|
||||
"App::Property", "The output location for the probe data to be written"
|
||||
),
|
||||
)
|
||||
|
||||
def nextpoint(self, startpoint=0.0, endpoint=0.0, count=3):
|
||||
curstep = 0
|
||||
dist = (endpoint - startpoint) / (count - 1)
|
||||
while curstep <= count-1:
|
||||
while curstep <= count - 1:
|
||||
yield startpoint + (curstep * dist)
|
||||
curstep += 1
|
||||
|
||||
def opExecute(self, obj):
|
||||
'''opExecute(obj) ... generate probe locations.'''
|
||||
"""opExecute(obj) ... generate probe locations."""
|
||||
PathLog.track()
|
||||
self.commandlist.append(Path.Command("(Begin Probing)"))
|
||||
|
||||
stock = PathUtils.findParentJob(obj).Stock
|
||||
bb = stock.Shape.BoundBox
|
||||
|
||||
openstring = '(PROBEOPEN {})'.format(obj.OutputFileName)
|
||||
openstring = "(PROBEOPEN {})".format(obj.OutputFileName)
|
||||
self.commandlist.append(Path.Command(openstring))
|
||||
self.commandlist.append(Path.Command("G0", {"Z": obj.ClearanceHeight.Value}))
|
||||
|
||||
for y in self.nextpoint(bb.YMin, bb.YMax, obj.PointCountY):
|
||||
for x in self.nextpoint(bb.XMin, bb.XMax, obj.PointCountX):
|
||||
self.commandlist.append(Path.Command("G0", {"X": x + obj.Xoffset.Value, "Y": y + obj.Yoffset.Value, "Z": obj.SafeHeight.Value}))
|
||||
self.commandlist.append(Path.Command("G38.2", {"Z": obj.FinalDepth.Value, "F": obj.ToolController.VertFeed.Value}))
|
||||
self.commandlist.append(
|
||||
Path.Command(
|
||||
"G0",
|
||||
{
|
||||
"X": x + obj.Xoffset.Value,
|
||||
"Y": y + obj.Yoffset.Value,
|
||||
"Z": obj.SafeHeight.Value,
|
||||
},
|
||||
)
|
||||
)
|
||||
self.commandlist.append(
|
||||
Path.Command(
|
||||
"G38.2",
|
||||
{
|
||||
"Z": obj.FinalDepth.Value,
|
||||
"F": obj.ToolController.VertFeed.Value,
|
||||
},
|
||||
)
|
||||
)
|
||||
self.commandlist.append(Path.Command("G0", {"Z": obj.SafeHeight.Value}))
|
||||
|
||||
self.commandlist.append(Path.Command("(PROBECLOSE)"))
|
||||
|
||||
def opSetDefaultValues(self, obj, job):
|
||||
'''opSetDefaultValues(obj, job) ... set default value for RetractHeight'''
|
||||
"""opSetDefaultValues(obj, job) ... set default value for RetractHeight"""
|
||||
|
||||
|
||||
def SetupProperties():
|
||||
setup = ['Xoffset', 'Yoffset', 'PointCountX', 'PointCountY', 'OutputFileName']
|
||||
setup = ["Xoffset", "Yoffset", "PointCountX", "PointCountY", "OutputFileName"]
|
||||
return setup
|
||||
|
||||
|
||||
def Create(name, obj=None, parentJob=None):
|
||||
'''Create(name) ... Creates and returns a Probing operation.'''
|
||||
"""Create(name) ... Creates and returns a Probing operation."""
|
||||
if obj is None:
|
||||
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
|
||||
proxy = ObjectProbing(obj, name, parentJob)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import PathGui as PGui # ensure Path/Gui/Resources are loaded
|
||||
import PathGui as PGui # ensure Path/Gui/Resources are loaded
|
||||
import PathScripts.PathProbe as PathProbe
|
||||
import PathScripts.PathOpGui as PathOpGui
|
||||
import PathScripts.PathGui as PathGui
|
||||
@@ -41,32 +41,36 @@ def translate(context, text, disambig=None):
|
||||
|
||||
|
||||
class TaskPanelOpPage(PathOpGui.TaskPanelPage):
|
||||
'''Page controller class for the Probing operation.'''
|
||||
"""Page controller class for the Probing operation."""
|
||||
|
||||
def getForm(self):
|
||||
'''getForm() ... returns UI'''
|
||||
"""getForm() ... returns UI"""
|
||||
return FreeCADGui.PySideUic.loadUi(":/panels/PageOpProbeEdit.ui")
|
||||
|
||||
def getFields(self, obj):
|
||||
'''getFields(obj) ... transfers values from UI to obj's proprties'''
|
||||
"""getFields(obj) ... transfers values from UI to obj's proprties"""
|
||||
self.updateToolController(obj, self.form.toolController)
|
||||
PathGui.updateInputField(obj, 'Xoffset', self.form.Xoffset)
|
||||
PathGui.updateInputField(obj, 'Yoffset', self.form.Yoffset)
|
||||
PathGui.updateInputField(obj, "Xoffset", self.form.Xoffset)
|
||||
PathGui.updateInputField(obj, "Yoffset", self.form.Yoffset)
|
||||
obj.PointCountX = self.form.PointCountX.value()
|
||||
obj.PointCountY = self.form.PointCountY.value()
|
||||
obj.OutputFileName = str(self.form.OutputFileName.text())
|
||||
|
||||
def setFields(self, obj):
|
||||
'''setFields(obj) ... transfers obj's property values to UI'''
|
||||
"""setFields(obj) ... transfers obj's property values to UI"""
|
||||
self.setupToolController(obj, self.form.toolController)
|
||||
self.form.Xoffset.setText(FreeCAD.Units.Quantity(obj.Xoffset.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.Yoffset.setText(FreeCAD.Units.Quantity(obj.Yoffset.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.Xoffset.setText(
|
||||
FreeCAD.Units.Quantity(obj.Xoffset.Value, FreeCAD.Units.Length).UserString
|
||||
)
|
||||
self.form.Yoffset.setText(
|
||||
FreeCAD.Units.Quantity(obj.Yoffset.Value, FreeCAD.Units.Length).UserString
|
||||
)
|
||||
self.form.OutputFileName.setText(obj.OutputFileName)
|
||||
self.form.PointCountX.setValue(obj.PointCountX)
|
||||
self.form.PointCountY.setValue(obj.PointCountY)
|
||||
|
||||
def getSignalsForUpdate(self, obj):
|
||||
'''getSignalsForUpdate(obj) ... return list of signals for updating obj'''
|
||||
"""getSignalsForUpdate(obj) ... return list of signals for updating obj"""
|
||||
signals = []
|
||||
signals.append(self.form.toolController.currentIndexChanged)
|
||||
signals.append(self.form.PointCountX.valueChanged)
|
||||
@@ -78,16 +82,25 @@ class TaskPanelOpPage(PathOpGui.TaskPanelPage):
|
||||
return signals
|
||||
|
||||
def SetOutputFileName(self):
|
||||
filename = QtGui.QFileDialog.getSaveFileName(self.form, translate("Path_Probe", "Select Output File"), None, translate("Path_Probe", "All Files (*.*)"))
|
||||
filename = QtGui.QFileDialog.getSaveFileName(
|
||||
self.form,
|
||||
translate("Path_Probe", "Select Output File"),
|
||||
None,
|
||||
translate("Path_Probe", "All Files (*.*)"),
|
||||
)
|
||||
if filename and filename[0]:
|
||||
self.obj.OutputFileName = str(filename[0])
|
||||
self.setFields(self.obj)
|
||||
|
||||
|
||||
Command = PathOpGui.SetupOperation('Probe', PathProbe.Create, TaskPanelOpPage,
|
||||
'Path_Probe',
|
||||
QtCore.QT_TRANSLATE_NOOP("Probe", "Probe"),
|
||||
QtCore.QT_TRANSLATE_NOOP("Probe", "Create a Probing Grid from a job stock"),
|
||||
PathProbe.SetupProperties)
|
||||
Command = PathOpGui.SetupOperation(
|
||||
"Probe",
|
||||
PathProbe.Create,
|
||||
TaskPanelOpPage,
|
||||
"Path_Probe",
|
||||
QtCore.QT_TRANSLATE_NOOP("Probe", "Probe"),
|
||||
QtCore.QT_TRANSLATE_NOOP("Probe", "Create a Probing Grid from a job stock"),
|
||||
PathProbe.SetupProperties,
|
||||
)
|
||||
|
||||
FreeCAD.Console.PrintLog("Loading PathProbeGui... done\n")
|
||||
|
||||
Reference in New Issue
Block a user