Path: adapt other operations
# Conflicts: # src/Mod/Path/Gui/Resources/panels/DrillingEdit.ui # src/Mod/Path/PathScripts/PathDrilling.py
This commit is contained in:
committed by
Yorik van Havre
parent
79e9f76252
commit
fa1f358f52
@@ -26,6 +26,11 @@ from __future__ import print_function
|
||||
import FreeCAD
|
||||
import Path
|
||||
from PathScripts import PathUtils
|
||||
import PathScripts.PathLog as PathLog
|
||||
|
||||
LOG_MODULE = 'PathSurface'
|
||||
PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE)
|
||||
#PathLog.trackModule('PathSurface')
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
@@ -51,33 +56,35 @@ except AttributeError:
|
||||
class ObjectSurface:
|
||||
|
||||
def __init__(self, obj):
|
||||
obj.addProperty("App::PropertyLinkSubList", "Base", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","The base geometry of this toolpath"))
|
||||
obj.addProperty("App::PropertyBool", "Active", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","Make False, to prevent operation from generating code"))
|
||||
obj.addProperty("App::PropertyString", "Comment", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","An optional comment for this profile"))
|
||||
obj.addProperty("App::PropertyString", "UserLabel", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property","User Assigned Label"))
|
||||
obj.addProperty("App::PropertyLinkSubList", "Base", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The base geometry of this toolpath"))
|
||||
obj.addProperty("App::PropertyBool", "Active", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "Make False, to prevent operation from generating code"))
|
||||
obj.addProperty("App::PropertyString", "Comment", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "An optional comment for this profile"))
|
||||
obj.addProperty("App::PropertyString", "UserLabel", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "User Assigned Label"))
|
||||
|
||||
obj.addProperty("App::PropertyEnumeration", "Algorithm", "Algorithm", QtCore.QT_TRANSLATE_NOOP("App::Property","The library to use to generate the path"))
|
||||
obj.addProperty("App::PropertyEnumeration", "Algorithm", "Algorithm", QtCore.QT_TRANSLATE_NOOP("App::Property", "The library to use to generate the path"))
|
||||
obj.Algorithm = ['OCL Dropcutter', 'OCL Waterline']
|
||||
|
||||
# Tool Properties
|
||||
obj.addProperty("App::PropertyIntegerConstraint", "ToolNumber", "Tool", QtCore.QT_TRANSLATE_NOOP("App::Property","The tool number in use"))
|
||||
obj.ToolNumber = (0, 0, 1000, 0)
|
||||
obj.setEditorMode('ToolNumber', 1) # make this read only
|
||||
obj.addProperty("App::PropertyString", "ToolDescription", "Tool", QtCore.QT_TRANSLATE_NOOP("App::Property","The description of the tool "))
|
||||
obj.setEditorMode('ToolDescription', 1) # make this read onlyt
|
||||
|
||||
# Surface Properties
|
||||
obj.addProperty("App::PropertyFloatConstraint", "SampleInterval", "Surface", QtCore.QT_TRANSLATE_NOOP("App::Property","The Sample Interval. Small values cause long wait"))
|
||||
obj.addProperty("App::PropertyFloatConstraint", "SampleInterval", "Surface", QtCore.QT_TRANSLATE_NOOP("App::Property", "The Sample Interval. Small values cause long wait"))
|
||||
obj.SampleInterval = (0, 0, 1, 0)
|
||||
|
||||
# Tool Properties
|
||||
obj.addProperty("App::PropertyLink", "ToolController", "Path", QtCore.QT_TRANSLATE_NOOP("App::Property", "The tool controller that will be used to calculate the path"))
|
||||
|
||||
# Depth Properties
|
||||
obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","The height needed to clear clamps and obstructions"))
|
||||
obj.addProperty("App::PropertyDistance", "SafeHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Rapid Safety Height between locations."))
|
||||
obj.addProperty("App::PropertyFloatConstraint", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Incremental Step Down of Tool"))
|
||||
obj.addProperty("App::PropertyDistance", "ClearanceHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "The height needed to clear clamps and obstructions"))
|
||||
obj.addProperty("App::PropertyDistance", "SafeHeight", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Rapid Safety Height between locations."))
|
||||
obj.addProperty("App::PropertyFloatConstraint", "StepDown", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Incremental Step Down of Tool"))
|
||||
obj.StepDown = (0.0, 0.01, 100.0, 0.5)
|
||||
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Starting Depth of Tool- first cut depth in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Final Depth of Tool- lowest value in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "FinishDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property","Maximum material removed on final pass."))
|
||||
obj.addProperty("App::PropertyDistance", "StartDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Starting Depth of Tool- first cut depth in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "FinalDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Final Depth of Tool- lowest value in Z"))
|
||||
obj.addProperty("App::PropertyDistance", "FinishDepth", "Depth", QtCore.QT_TRANSLATE_NOOP("App::Property", "Maximum material removed on final pass."))
|
||||
|
||||
self.vertFeed = 0.0
|
||||
self.horizFeed = 0.0
|
||||
self.vertRapid = 0.0
|
||||
self.horizRapid = 0.0
|
||||
self.radius = 0.0
|
||||
|
||||
obj.Proxy = self
|
||||
|
||||
@@ -258,32 +265,20 @@ class ObjectSurface:
|
||||
if obj.Comment != "":
|
||||
output += '(' + str(obj.Comment)+')\n'
|
||||
|
||||
toolLoad = PathUtils.getLastToolLoad(obj)
|
||||
toolLoad = obj.ToolController
|
||||
if toolLoad is None or toolLoad.ToolNumber == 0:
|
||||
self.vertFeed = 100
|
||||
self.horizFeed = 100
|
||||
self.vertRapid = 100
|
||||
self.horizRapid = 100
|
||||
self.radius = 0.25
|
||||
obj.ToolNumber = 0
|
||||
obj.ToolDescription = "UNDEFINED"
|
||||
FreeCAD.Console.PrintError("No Tool Controller is selected. We need a tool to build a Path.")
|
||||
else:
|
||||
self.vertFeed = toolLoad.VertFeed.Value
|
||||
self.horizFeed = toolLoad.HorizFeed.Value
|
||||
self.vertRapid = toolLoad.VertRapid.Value
|
||||
self.horizRapid = toolLoad.HorizRapid.Value
|
||||
tool = PathUtils.getTool(obj, toolLoad.ToolNumber)
|
||||
if tool.Diameter == 0:
|
||||
self.radius = 0.25
|
||||
tool = toolLoad.Proxy.getTool(toolLoad)
|
||||
if not tool or tool.Diameter == 0:
|
||||
FreeCAD.Console.PrintError("No Tool found or diameter is zero. We need a tool to build a Path.")
|
||||
return
|
||||
else:
|
||||
self.radius = tool.Diameter/2
|
||||
obj.ToolNumber = toolLoad.ToolNumber
|
||||
obj.ToolDescription = toolLoad.Name
|
||||
|
||||
if obj.UserLabel == "":
|
||||
obj.Label = obj.Name + " :" + obj.ToolDescription
|
||||
else:
|
||||
obj.Label = obj.UserLabel + " :" + obj.ToolDescription
|
||||
|
||||
output += "(" + obj.Label + ")"
|
||||
output += "(Compensated Tool Path. Diameter: " + str(self.radius * 2) + ")"
|
||||
@@ -299,8 +294,6 @@ class ObjectSurface:
|
||||
return
|
||||
print("base object: " + mesh.Name)
|
||||
|
||||
|
||||
|
||||
if obj.Algorithm in ['OCL Dropcutter', 'OCL Waterline']:
|
||||
try:
|
||||
import ocl
|
||||
@@ -309,7 +302,6 @@ class ObjectSurface:
|
||||
"PathSurface", "This operation requires OpenCamLib to be installed.\n"))
|
||||
return
|
||||
|
||||
#mesh = b[0]
|
||||
if mesh.TypeId.startswith('Mesh'):
|
||||
mesh = mesh.Mesh
|
||||
bb = mesh.BoundBox
|
||||
@@ -341,6 +333,7 @@ class ObjectSurface:
|
||||
obj.Path = path
|
||||
obj.ViewObject.Visibility = False
|
||||
|
||||
|
||||
class ViewProviderSurface:
|
||||
|
||||
def __init__(self, obj): # mandatory
|
||||
@@ -459,6 +452,10 @@ class TaskPanel:
|
||||
if hasattr(self.obj, "Algorithm"):
|
||||
self.obj.Algorithm = str(
|
||||
self.form.algorithmSelect.currentText())
|
||||
if hasattr(self.obj, "ToolController"):
|
||||
PathLog.debug("name: {}".format(self.form.uiToolController.currentText()))
|
||||
tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText())
|
||||
self.obj.ToolController = tc
|
||||
|
||||
self.obj.Proxy.execute(self.obj)
|
||||
|
||||
@@ -470,13 +467,31 @@ class TaskPanel:
|
||||
self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString)
|
||||
|
||||
controllers = PathUtils.getToolControllers(self.obj)
|
||||
labels = [c.Label for c in controllers]
|
||||
self.form.uiToolController.blockSignals(True)
|
||||
self.form.uiToolController.addItems(labels)
|
||||
self.form.uiToolController.blockSignals(False)
|
||||
if self.obj.ToolController is not None:
|
||||
index = self.form.uiToolController.findText(
|
||||
self.obj.ToolController.Label, QtCore.Qt.MatchFixedString)
|
||||
PathLog.debug("searching for TC label {}. Found Index: {}".format(self.obj.ToolController.Label, index))
|
||||
if index >= 0:
|
||||
self.form.uiToolController.blockSignals(True)
|
||||
self.form.uiToolController.setCurrentIndex(index)
|
||||
self.form.uiToolController.blockSignals(False)
|
||||
else:
|
||||
self.obj.ToolController = PathUtils.findToolController(self.obj)
|
||||
|
||||
for i in self.obj.Base:
|
||||
self.form.baseList.addItem(i[0].Name)
|
||||
|
||||
index = self.form.algorithmSelect.findText(
|
||||
self.obj.Algorithm, QtCore.Qt.MatchFixedString)
|
||||
if index >= 0:
|
||||
self.form.algorithmSelect.blockSignals(True)
|
||||
self.form.algorithmSelect.setCurrentIndex(index)
|
||||
self.form.algorithmSelect.blockSignals(False)
|
||||
|
||||
def open(self):
|
||||
self.s = SelObserver()
|
||||
@@ -554,14 +569,12 @@ class TaskPanel:
|
||||
return int(QtGui.QDialogButtonBox.Ok)
|
||||
|
||||
def setupUi(self):
|
||||
|
||||
# Connect Signals and Slots
|
||||
|
||||
#Base Geometry
|
||||
# Base Geometry
|
||||
self.form.addBase.clicked.connect(self.addBase)
|
||||
self.form.deleteBase.clicked.connect(self.deleteBase)
|
||||
self.form.reorderBase.clicked.connect(self.reorderBase)
|
||||
self.form.baseList.itemSelectionChanged.connect(self.itemActivated)
|
||||
self.form.uiToolController.currentIndexChanged.connect(self.getFields)
|
||||
|
||||
# Depths
|
||||
self.form.startDepth.editingFinished.connect(self.getFields)
|
||||
|
||||
Reference in New Issue
Block a user