diff --git a/src/Mod/Path/PathScripts/DlgSettingsPath.ui b/src/Mod/Path/PathScripts/DlgSettingsPath.ui
index 6eb41293e..a8d112f7d 100644
--- a/src/Mod/Path/PathScripts/DlgSettingsPath.ui
+++ b/src/Mod/Path/PathScripts/DlgSettingsPath.ui
@@ -31,72 +31,16 @@
-
- If this is checked, object names will be prefixed with the IFC ID number
+ If this option is enabled, new paths will automatically be placed in the active project, which will be created if necessary.
- Test setting 1
+ Automatic project handling
+
+
+ true
- pathTestSetting1
-
-
- Mod/Path
-
-
-
-
-
- -
-
-
-
-
-
- Test setting 2
-
-
-
- -
-
-
- A comma-separated list of Ifc entities to exclude from import
-
-
-
-
-
-
-
-
- pathTestSetting2
-
-
- Mod/Path
-
-
-
-
-
-
-
-
- -
-
-
- Test group
-
-
-
-
-
-
-
-
-
- Some IFC viewers don't like objects exported as extrusions. Use this to force all objects to be exported as BREP geometry.
-
-
- Test setting 3
-
-
- pathTestSetting3
+ pathAutoProject
Mod/Path
@@ -131,11 +75,6 @@
QCheckBox
-
- Gui::PrefLineEdit
- QLineEdit
-
-
diff --git a/src/Mod/Path/PathScripts/PathArray.py b/src/Mod/Path/PathScripts/PathArray.py
index af0b802dd..c9e9be883 100644
--- a/src/Mod/Path/PathScripts/PathArray.py
+++ b/src/Mod/Path/PathScripts/PathArray.py
@@ -123,11 +123,13 @@ class CommandPathArray:
# if everything is ok, execute and register the transaction in the undo/redo stack
FreeCAD.ActiveDocument.openTransaction("Create Array")
FreeCADGui.addModule("PathScripts.PathArray")
+ FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Array")')
FreeCADGui.doCommand('PathScripts.PathArray.ObjectArray(obj)')
FreeCADGui.doCommand('obj.Base = (FreeCAD.ActiveDocument.' + selection[0].Name + ')')
#FreeCADGui.doCommand('PathScripts.PathArray.ViewProviderArray(obj.ViewObject)')
FreeCADGui.doCommand('obj.ViewObject.Proxy = 0')
+ FreeCADGui.doCommand('PathScripts.PathUtils.addToProject(obj)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Path/PathScripts/PathCustom.py b/src/Mod/Path/PathScripts/PathCustom.py
index f7c0af067..3745239ed 100644
--- a/src/Mod/Path/PathScripts/PathCustom.py
+++ b/src/Mod/Path/PathScripts/PathCustom.py
@@ -74,9 +74,11 @@ class CommandPathCustom:
def Activated(self):
FreeCAD.ActiveDocument.openTransaction("Create Custom Path")
FreeCADGui.addModule("PathScripts.PathCustom")
+ FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Custom")')
FreeCADGui.doCommand('PathScripts.PathCustom.ObjectCustom(obj)')
FreeCADGui.doCommand('obj.ViewObject.Proxy = 0')
+ FreeCADGui.doCommand('PathScripts.PathUtils.addToProject(obj)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Path/PathScripts/PathFacePocket.py b/src/Mod/Path/PathScripts/PathFacePocket.py
index c7a71a94d..772bcc1e4 100644
--- a/src/Mod/Path/PathScripts/PathFacePocket.py
+++ b/src/Mod/Path/PathScripts/PathFacePocket.py
@@ -171,6 +171,7 @@ class CommandPathFacePocket:
# if everything is ok, execute and register the transaction in the undo/redo stack
FreeCAD.ActiveDocument.openTransaction("Create Pocket")
FreeCADGui.addModule("PathScripts.PathFacePocket")
+ FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","FacePocket")')
FreeCADGui.doCommand('PathScripts.PathFacePocket.ObjectFacePocket(obj)')
subs = "["
@@ -179,6 +180,7 @@ class CommandPathFacePocket:
subs += "]"
FreeCADGui.doCommand('obj.Base = (FreeCAD.ActiveDocument.' + selection[0].ObjectName + ',' + subs + ')')
FreeCADGui.doCommand('obj.ViewObject.Proxy = 0')
+ FreeCADGui.doCommand('PathScripts.PathUtils.addToProject(obj)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Path/PathScripts/PathFaceProfile.py b/src/Mod/Path/PathScripts/PathFaceProfile.py
index 8133d1620..b5beeec4b 100644
--- a/src/Mod/Path/PathScripts/PathFaceProfile.py
+++ b/src/Mod/Path/PathScripts/PathFaceProfile.py
@@ -134,10 +134,12 @@ class CommandPathFaceProfile:
# if everything is ok, execute and register the transaction in the undo/redo stack
FreeCAD.ActiveDocument.openTransaction("Create Profile")
FreeCADGui.addModule("PathScripts.PathFaceProfile")
+ FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","FaceProfile")')
FreeCADGui.doCommand('PathScripts.PathFaceProfile.ObjectFaceProfile(obj)')
FreeCADGui.doCommand('obj.Base = (FreeCAD.ActiveDocument.'+selection[0].ObjectName+',"'+selection[0].SubElementNames[0]+'")')
FreeCADGui.doCommand('obj.ViewObject.Proxy = 0')
+ FreeCADGui.doCommand('PathScripts.PathUtils.addToProject(obj)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Path/PathScripts/PathFromShape.py b/src/Mod/Path/PathScripts/PathFromShape.py
index 118676aeb..37fc149c9 100644
--- a/src/Mod/Path/PathScripts/PathFromShape.py
+++ b/src/Mod/Path/PathScripts/PathFromShape.py
@@ -95,8 +95,10 @@ class CommandFromShape:
return
FreeCAD.ActiveDocument.openTransaction(translate("Path_FromShape","Create path from shape"))
+ FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand("obj = FreeCAD.activeDocument().addObject('Path::FeatureShape','PathShape')")
FreeCADGui.doCommand("obj.Shape = FreeCAD.activeDocument()."+selection[0].Name+".Shape")
+ FreeCADGui.doCommand('PathScripts.PathUtils.addToProject(obj)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Path/PathScripts/PathHop.py b/src/Mod/Path/PathScripts/PathHop.py
index 7d90b2af9..a8b11ef8d 100644
--- a/src/Mod/Path/PathScripts/PathHop.py
+++ b/src/Mod/Path/PathScripts/PathHop.py
@@ -121,6 +121,7 @@ class CommandPathHop:
FreeCAD.ActiveDocument.openTransaction(translate("PathHop","Create Hop"))
FreeCADGui.addModule("PathScripts.PathHop")
+ FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Hop")')
FreeCADGui.doCommand('PathScripts.PathHop.ObjectHop(obj)')
FreeCADGui.doCommand('PathScripts.PathHop.ViewProviderPathHop(obj.ViewObject)')
diff --git a/src/Mod/Path/PathScripts/PathSimpleCopy.py b/src/Mod/Path/PathScripts/PathSimpleCopy.py
index 2a087efe2..adadea635 100644
--- a/src/Mod/Path/PathScripts/PathSimpleCopy.py
+++ b/src/Mod/Path/PathScripts/PathSimpleCopy.py
@@ -60,8 +60,10 @@ class CommandPathSimpleCopy:
return
FreeCAD.ActiveDocument.openTransaction(translate("Path_SimpleCopy","Simple Copy"))
- FreeCADGui.doCommand('copy = FreeCAD.ActiveDocument.addObject("Path::Feature","'+selection[0].Name+ '_copy")')
- FreeCADGui.doCommand('copy.Path = FreeCAD.ActiveDocument.'+selection[0].Name+'.Path')
+ FreeCADGui.addModule("PathScripts.PathUtils")
+ FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::Feature","'+selection[0].Name+ '_copy")')
+ FreeCADGui.doCommand('obj.Path = FreeCAD.ActiveDocument.'+selection[0].Name+'.Path')
+ FreeCADGui.doCommand('PathScripts.PathUtils.addToProject(obj)')
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
diff --git a/src/Mod/Path/PathScripts/PathUtils.py b/src/Mod/Path/PathScripts/PathUtils.py
index 90e5de3c6..0e5464da3 100644
--- a/src/Mod/Path/PathScripts/PathUtils.py
+++ b/src/Mod/Path/PathScripts/PathUtils.py
@@ -359,17 +359,17 @@ def findMachine():
return o
def addToProject(obj):
- """Adds a path obj to this document, if no PathParoject exists it's created on the fly"""
+ """Adds a path obj to this document, if no PathParoject exists it's created on the fly"""
+ p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Path")
+ if p.GetBool("pathAutoProject",True):
project = findProj()
-
- if project == None:
+ if not project:
project = PathProject.CommandProject.Create()
-
g = project.Group
g.append(obj)
project.Group = g
-
return project
+ return None
def getLastZ(obj):