diff --git a/src/Mod/Path/Gui/Resources/preferences/PathJob.ui b/src/Mod/Path/Gui/Resources/preferences/PathJob.ui
index 2e84541bbc..7d88c71040 100644
--- a/src/Mod/Path/Gui/Resources/preferences/PathJob.ui
+++ b/src/Mod/Path/Gui/Resources/preferences/PathJob.ui
@@ -24,8 +24,8 @@
0
0
- 422
- 558
+ 467
+ 448
@@ -142,8 +142,8 @@
0
0
- 406
- 360
+ 665
+ 449
@@ -348,8 +348,8 @@
0
0
- 422
- 558
+ 431
+ 718
@@ -620,6 +620,49 @@
+
+
+ Tools
+
+
+ -
+
+
+ <html><head/><body><p>Legacy Tools have no accurate shape representation and are stored in the user preferences of FreeCAD.</p></body></html>
+
+
+ Use Legacy Tools
+
+
+
+ -
+
+
+ <html><head/><body><p>References to Tool Bits and their shapes can either be stored with an absolute path or with a relative path to the search path.</p><p><br/></p><p>Generally it is recommended to use relative paths due to their flexibility and robustness to layout changes.</p><p><br/></p><p>Should multiple tools or tool shapes with the same name exist in different directories it can be required to use absolute paths. </p></body></html>
+
+
+ Store Relative Paths
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
diff --git a/src/Mod/Path/PathScripts/PathPreferences.py b/src/Mod/Path/PathScripts/PathPreferences.py
index f03141ef86..37e16d98ab 100644
--- a/src/Mod/Path/PathScripts/PathPreferences.py
+++ b/src/Mod/Path/PathScripts/PathPreferences.py
@@ -43,7 +43,10 @@ PostProcessorOutputPolicy = "PostProcessorOutputPolicy"
LastPathToolBit = "LastPathToolBit"
LastPathToolLibrary = "LastPathToolLibrary"
-LastPathToolShape = "LastPathToolShape"
+LastPathToolShape = "LastPathToolShape"
+
+UseLegacyTools = "UseLegacyTools"
+UseRelativeToolPaths = "UseRelativeToolPaths"
# Linear tolerance to use when generating Paths, eg when tessellating geometry
GeometryTolerance = "GeometryTolerance"
@@ -146,6 +149,17 @@ def searchPathsTool(sub='Bit'):
appendPath(os.path.join(FreeCAD.getHomePath(), "Mod/Path/"), sub)
return paths
+def toolsUseLegacyTools():
+ return preferences().GetBool(UseLegacyTools, True)
+
+def toolsStoreRelativePaths():
+ return preferences().GetBool(UseRelativeToolPaths, True)
+
+def setToolsSettings(legacy, relative):
+ pref = preferences()
+ pref.SetBool(UseLegacyTools, legacy)
+ pref.SetBool(UseRelativeToolPaths, relative)
+
def defaultJobTemplate():
template = preferences().GetString(DefaultJobTemplate)
if 'xml' not in template:
diff --git a/src/Mod/Path/PathScripts/PathPreferencesPathJob.py b/src/Mod/Path/PathScripts/PathPreferencesPathJob.py
index 1c5efdf1bf..525ba9c6e1 100644
--- a/src/Mod/Path/PathScripts/PathPreferencesPathJob.py
+++ b/src/Mod/Path/PathScripts/PathPreferencesPathJob.py
@@ -71,6 +71,7 @@ class JobPreferencesPage:
policy = str(self.form.cboOutputPolicy.currentText())
PathPreferences.setOutputFileDefaults(path, policy)
self.saveStockSettings()
+ self.saveToolsSettings()
def saveStockSettings(self):
if self.form.stockGroup.isChecked():
@@ -107,6 +108,9 @@ class JobPreferencesPage:
else:
PathPreferences.setDefaultStockTemplate('')
+ def saveToolsSettings(self):
+ PathPreferences.setToolsSettings(self.form.toolsUseLegacy.isChecked(), self.form.toolsRelativePaths.isChecked())
+
def selectComboEntry(self, widget, text):
index = widget.findText(text, QtCore.Qt.MatchFixedString)
if index >= 0:
@@ -167,6 +171,7 @@ class JobPreferencesPage:
self.form.tbOutputFile.clicked.connect(self.browseOutputFile)
self.loadStockSettings()
+ self.loadToolSettings()
def loadStockSettings(self):
stock = PathPreferences.defaultStockTemplate()
@@ -244,6 +249,10 @@ class JobPreferencesPage:
self.form.stockCreateBox.hide()
self.form.stockCreateCylinder.hide()
+ def loadToolSettings(self):
+ self.form.toolsUseLegacy.setChecked(PathPreferences.toolsUseLegacyTools())
+ self.form.toolsRelativePaths.setChecked(PathPreferences.toolsStoreRelativePaths())
+
def getPostProcessor(self, name):
if not name in self.processor.keys():
processor = PostProcessor.load(name)
diff --git a/src/Mod/Path/PathScripts/PathToolBitLibraryCmd.py b/src/Mod/Path/PathScripts/PathToolBitLibraryCmd.py
index 0583f77db5..ae5573013b 100644
--- a/src/Mod/Path/PathScripts/PathToolBitLibraryCmd.py
+++ b/src/Mod/Path/PathScripts/PathToolBitLibraryCmd.py
@@ -74,15 +74,22 @@ class CommandToolBitLibraryLoad:
return not self.selectedJob() is None
def Activated(self):
+ job = self.selectedJob()
+ self.Execute(job)
+
+ @classmethod
+ def Execute(cls, job):
import PathScripts.PathToolBitLibraryGui as PathToolBitLibraryGui
import PathScripts.PathToolControllerGui as PathToolControllerGui
- job = self.selectedJob()
+
library = PathToolBitLibraryGui.ToolBitLibrary()
- if 1 == library.open(dialog=True):
+ if 1 == library.open(dialog=True) and job:
for nr, tool in library.selectedOrAllTools():
tc = PathToolControllerGui.Create("TC: {}".format(tool.Label), tool, nr)
job.Proxy.addToolController(tc)
FreeCAD.ActiveDocument.recompute()
+ return True
+ return False
if FreeCAD.GuiUp:
FreeCADGui.addCommand('Path_ToolBitLibraryOpen', CommandToolBitLibraryOpen())
diff --git a/src/Mod/Path/PathScripts/PathToolController.py b/src/Mod/Path/PathScripts/PathToolController.py
index 96cc49e8e3..5cf6eead07 100644
--- a/src/Mod/Path/PathScripts/PathToolController.py
+++ b/src/Mod/Path/PathScripts/PathToolController.py
@@ -26,6 +26,7 @@
import FreeCAD
import Path
import PathScripts.PathLog as PathLog
+import PathScripts.PathPreferences as PathPreferences
import PathScripts.PathToolBit as PathToolBit
from PySide import QtCore
@@ -195,20 +196,25 @@ class ToolController:
def Create(name = 'Default Tool', tool=None, toolNumber=1, assignViewProvider=True):
PathLog.track(tool, toolNumber)
+ legacyTool = PathPreferences.toolsUseLegacyTools() if tool is None else isinstance(tool, Path.Tool)
+
obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", name)
obj.Label = name
- obj.Proxy = ToolController(obj, tool is None or isinstance(tool, Path.Tool))
+ obj.Proxy = ToolController(obj, legacyTool)
if FreeCAD.GuiUp and assignViewProvider:
ViewProvider(obj.ViewObject)
if tool is None:
- tool = Path.Tool()
- tool.Diameter = 5.0
- tool.Name = "Default Tool"
- tool.CuttingEdgeHeight = 15.0
- tool.ToolType = "EndMill"
- tool.Material = "HighSpeedSteel"
+ if legacyTool:
+ tool = Path.Tool()
+ tool.Diameter = 5.0
+ tool.Name = "Default Tool"
+ tool.CuttingEdgeHeight = 15.0
+ tool.ToolType = "EndMill"
+ tool.Material = "HighSpeedSteel"
+ else:
+ tool = PathToolBit.Factory.Create()
obj.Tool = tool
obj.ToolNumber = toolNumber
diff --git a/src/Mod/Path/PathScripts/PathToolLibraryEditor.py b/src/Mod/Path/PathScripts/PathToolLibraryEditor.py
index 9e867f4ce6..367955a288 100644
--- a/src/Mod/Path/PathScripts/PathToolLibraryEditor.py
+++ b/src/Mod/Path/PathScripts/PathToolLibraryEditor.py
@@ -29,6 +29,8 @@ import FreeCADGui
import Path
import PathScripts
import PathScripts.PathLog as PathLog
+import PathScripts.PathPreferences as PathPreferences
+import PathScripts.PathToolBitLibraryCmd as PathToolBitLibraryCmd
import PathScripts.PathToolEdit as PathToolEdit
import PathScripts.PathUtils as PathUtils
import PathScripts.PathToolLibraryManager as ToolLibraryManager
@@ -439,12 +441,14 @@ class CommandToolLibraryEdit():
pass
def edit(self, job=None, cb=None):
- editor = EditorPanel(job, cb)
- editor.setupUi()
-
- r = editor.form.exec_()
- if r:
- pass
+ if PathPreferences.toolsUseLegacyTools():
+ editor = EditorPanel(job, cb)
+ editor.setupUi()
+ editor.form.exec_()
+ else:
+ if PathToolBitLibraryCmd.CommandToolBitLibraryLoad.Execute(job):
+ if cb:
+ cb()
def GetResources(self):
return {'Pixmap' : 'Path-ToolTable',
@@ -456,7 +460,6 @@ class CommandToolLibraryEdit():
return not FreeCAD.ActiveDocument is None
def Activated(self):
-
self.edit()
if FreeCAD.GuiUp: