Path: Added pref setting to disable auto-include of new paths in projects

This commit is contained in:
Yorik van Havre 2016-01-24 21:04:02 -02:00
parent a691fec1dd
commit cbdd18cef6
9 changed files with 26 additions and 74 deletions

View File

@ -31,72 +31,16 @@
<item> <item>
<widget class="Gui::PrefCheckBox" name="pathTestSetting1"> <widget class="Gui::PrefCheckBox" name="pathTestSetting1">
<property name="toolTip"> <property name="toolTip">
<string>If this is checked, object names will be prefixed with the IFC ID number</string> <string>If this option is enabled, new paths will automatically be placed in the active project, which will be created if necessary.</string>
</property> </property>
<property name="text"> <property name="text">
<string>Test setting 1</string> <string>Automatic project handling</string>
</property>
<property name="checked">
<bool>true</bool>
</property> </property>
<property name="prefEntry" stdset="0"> <property name="prefEntry" stdset="0">
<cstring>pathTestSetting1</cstring> <cstring>pathAutoProject</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Test setting 2</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefLineEdit" name="pathTestSetting2">
<property name="toolTip">
<string>A comma-separated list of Ifc entities to exclude from import</string>
</property>
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>pathTestSetting2</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Test group</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="Gui::PrefCheckBox" name="pathTestSetting3">
<property name="toolTip">
<string>Some IFC viewers don't like objects exported as extrusions. Use this to force all objects to be exported as BREP geometry.</string>
</property>
<property name="text">
<string>Test setting 3</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>pathTestSetting3</cstring>
</property> </property>
<property name="prefPath" stdset="0"> <property name="prefPath" stdset="0">
<cstring>Mod/Path</cstring> <cstring>Mod/Path</cstring>
@ -131,11 +75,6 @@
<extends>QCheckBox</extends> <extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header> <header>Gui/PrefWidgets.h</header>
</customwidget> </customwidget>
<customwidget>
<class>Gui::PrefLineEdit</class>
<extends>QLineEdit</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -123,11 +123,13 @@ class CommandPathArray:
# if everything is ok, execute and register the transaction in the undo/redo stack # if everything is ok, execute and register the transaction in the undo/redo stack
FreeCAD.ActiveDocument.openTransaction("Create Array") FreeCAD.ActiveDocument.openTransaction("Create Array")
FreeCADGui.addModule("PathScripts.PathArray") FreeCADGui.addModule("PathScripts.PathArray")
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Array")') FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Array")')
FreeCADGui.doCommand('PathScripts.PathArray.ObjectArray(obj)') FreeCADGui.doCommand('PathScripts.PathArray.ObjectArray(obj)')
FreeCADGui.doCommand('obj.Base = (FreeCAD.ActiveDocument.' + selection[0].Name + ')') FreeCADGui.doCommand('obj.Base = (FreeCAD.ActiveDocument.' + selection[0].Name + ')')
#FreeCADGui.doCommand('PathScripts.PathArray.ViewProviderArray(obj.ViewObject)') #FreeCADGui.doCommand('PathScripts.PathArray.ViewProviderArray(obj.ViewObject)')
FreeCADGui.doCommand('obj.ViewObject.Proxy = 0') FreeCADGui.doCommand('obj.ViewObject.Proxy = 0')
FreeCADGui.doCommand('PathScripts.PathUtils.addToProject(obj)')
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()

View File

@ -74,9 +74,11 @@ class CommandPathCustom:
def Activated(self): def Activated(self):
FreeCAD.ActiveDocument.openTransaction("Create Custom Path") FreeCAD.ActiveDocument.openTransaction("Create Custom Path")
FreeCADGui.addModule("PathScripts.PathCustom") FreeCADGui.addModule("PathScripts.PathCustom")
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Custom")') FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Custom")')
FreeCADGui.doCommand('PathScripts.PathCustom.ObjectCustom(obj)') FreeCADGui.doCommand('PathScripts.PathCustom.ObjectCustom(obj)')
FreeCADGui.doCommand('obj.ViewObject.Proxy = 0') FreeCADGui.doCommand('obj.ViewObject.Proxy = 0')
FreeCADGui.doCommand('PathScripts.PathUtils.addToProject(obj)')
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()

View File

@ -171,6 +171,7 @@ class CommandPathFacePocket:
# if everything is ok, execute and register the transaction in the undo/redo stack # if everything is ok, execute and register the transaction in the undo/redo stack
FreeCAD.ActiveDocument.openTransaction("Create Pocket") FreeCAD.ActiveDocument.openTransaction("Create Pocket")
FreeCADGui.addModule("PathScripts.PathFacePocket") FreeCADGui.addModule("PathScripts.PathFacePocket")
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","FacePocket")') FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","FacePocket")')
FreeCADGui.doCommand('PathScripts.PathFacePocket.ObjectFacePocket(obj)') FreeCADGui.doCommand('PathScripts.PathFacePocket.ObjectFacePocket(obj)')
subs = "[" subs = "["
@ -179,6 +180,7 @@ class CommandPathFacePocket:
subs += "]" subs += "]"
FreeCADGui.doCommand('obj.Base = (FreeCAD.ActiveDocument.' + selection[0].ObjectName + ',' + subs + ')') FreeCADGui.doCommand('obj.Base = (FreeCAD.ActiveDocument.' + selection[0].ObjectName + ',' + subs + ')')
FreeCADGui.doCommand('obj.ViewObject.Proxy = 0') FreeCADGui.doCommand('obj.ViewObject.Proxy = 0')
FreeCADGui.doCommand('PathScripts.PathUtils.addToProject(obj)')
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()

View File

@ -134,10 +134,12 @@ class CommandPathFaceProfile:
# if everything is ok, execute and register the transaction in the undo/redo stack # if everything is ok, execute and register the transaction in the undo/redo stack
FreeCAD.ActiveDocument.openTransaction("Create Profile") FreeCAD.ActiveDocument.openTransaction("Create Profile")
FreeCADGui.addModule("PathScripts.PathFaceProfile") FreeCADGui.addModule("PathScripts.PathFaceProfile")
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","FaceProfile")') FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","FaceProfile")')
FreeCADGui.doCommand('PathScripts.PathFaceProfile.ObjectFaceProfile(obj)') FreeCADGui.doCommand('PathScripts.PathFaceProfile.ObjectFaceProfile(obj)')
FreeCADGui.doCommand('obj.Base = (FreeCAD.ActiveDocument.'+selection[0].ObjectName+',"'+selection[0].SubElementNames[0]+'")') FreeCADGui.doCommand('obj.Base = (FreeCAD.ActiveDocument.'+selection[0].ObjectName+',"'+selection[0].SubElementNames[0]+'")')
FreeCADGui.doCommand('obj.ViewObject.Proxy = 0') FreeCADGui.doCommand('obj.ViewObject.Proxy = 0')
FreeCADGui.doCommand('PathScripts.PathUtils.addToProject(obj)')
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()

View File

@ -95,8 +95,10 @@ class CommandFromShape:
return return
FreeCAD.ActiveDocument.openTransaction(translate("Path_FromShape","Create path from shape")) 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 = FreeCAD.activeDocument().addObject('Path::FeatureShape','PathShape')")
FreeCADGui.doCommand("obj.Shape = FreeCAD.activeDocument()."+selection[0].Name+".Shape") FreeCADGui.doCommand("obj.Shape = FreeCAD.activeDocument()."+selection[0].Name+".Shape")
FreeCADGui.doCommand('PathScripts.PathUtils.addToProject(obj)')
FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()

View File

@ -121,6 +121,7 @@ class CommandPathHop:
FreeCAD.ActiveDocument.openTransaction(translate("PathHop","Create Hop")) FreeCAD.ActiveDocument.openTransaction(translate("PathHop","Create Hop"))
FreeCADGui.addModule("PathScripts.PathHop") FreeCADGui.addModule("PathScripts.PathHop")
FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Hop")') FreeCADGui.doCommand('obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython","Hop")')
FreeCADGui.doCommand('PathScripts.PathHop.ObjectHop(obj)') FreeCADGui.doCommand('PathScripts.PathHop.ObjectHop(obj)')
FreeCADGui.doCommand('PathScripts.PathHop.ViewProviderPathHop(obj.ViewObject)') FreeCADGui.doCommand('PathScripts.PathHop.ViewProviderPathHop(obj.ViewObject)')

View File

@ -60,8 +60,10 @@ class CommandPathSimpleCopy:
return return
FreeCAD.ActiveDocument.openTransaction(translate("Path_SimpleCopy","Simple Copy")) FreeCAD.ActiveDocument.openTransaction(translate("Path_SimpleCopy","Simple Copy"))
FreeCADGui.doCommand('copy = FreeCAD.ActiveDocument.addObject("Path::Feature","'+selection[0].Name+ '_copy")') FreeCADGui.addModule("PathScripts.PathUtils")
FreeCADGui.doCommand('copy.Path = FreeCAD.ActiveDocument.'+selection[0].Name+'.Path') 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.commitTransaction()
FreeCAD.ActiveDocument.recompute() FreeCAD.ActiveDocument.recompute()

View File

@ -359,17 +359,17 @@ def findMachine():
return o return o
def addToProject(obj): 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() project = findProj()
if not project:
if project == None:
project = PathProject.CommandProject.Create() project = PathProject.CommandProject.Create()
g = project.Group g = project.Group
g.append(obj) g.append(obj)
project.Group = g project.Group = g
return project return project
return None
def getLastZ(obj): def getLastZ(obj):