diff --git a/src/Mod/Part/BOPTools/SplitFeatures.py b/src/Mod/Part/BOPTools/SplitFeatures.py
index 82563cd0d3..5ba297b3a1 100644
--- a/src/Mod/Part/BOPTools/SplitFeatures.py
+++ b/src/Mod/Part/BOPTools/SplitFeatures.py
@@ -251,22 +251,22 @@ class ViewProviderSlice:
FreeCAD.Console.PrintError("Error in onDelete: " + str(err))
return True
-def cmdCreateSliceFeature(name, mode):
+def cmdCreateSliceFeature(name, mode, transaction= True):
"""cmdCreateSliceFeature(name, mode): implementation of GUI command to create
Slice feature. Mode can be "Standard", "Split", or "CompSolid"."""
sel = FreeCADGui.Selection.getSelectionEx()
- FreeCAD.ActiveDocument.openTransaction("Create Slice")
+ if transaction: FreeCAD.ActiveDocument.openTransaction("Create Slice")
FreeCADGui.addModule("BOPTools.SplitFeatures")
- FreeCADGui.doCommand("j = BOPTools.SplitFeatures.makeSlice(name= '{name}')".format(name= name))
- FreeCADGui.doCommand("j.Base = {sel}[0]\n"
- "j.Tools = {sel}[1:]".format(
+ FreeCADGui.doCommand("f = BOPTools.SplitFeatures.makeSlice(name= '{name}')".format(name= name))
+ FreeCADGui.doCommand("f.Base = {sel}[0]\n"
+ "f.Tools = {sel}[1:]".format(
sel= "[" + ", ".join(["App.ActiveDocument."+so.Object.Name for so in sel]) + "]"
))
- FreeCADGui.doCommand("j.Mode = {mode}".format(mode= repr(mode)))
+ FreeCADGui.doCommand("f.Mode = {mode}".format(mode= repr(mode)))
try:
- FreeCADGui.doCommand("j.Proxy.execute(j)")
- FreeCADGui.doCommand("j.purgeTouched()")
+ FreeCADGui.doCommand("f.Proxy.execute(f)")
+ FreeCADGui.doCommand("f.purgeTouched()")
except Exception as err:
mb = QtGui.QMessageBox()
mb.setIcon(mb.Icon.Warning)
@@ -280,21 +280,36 @@ def cmdCreateSliceFeature(name, mode):
mb.exec_()
if mb.clickedButton() is btnAbort:
- FreeCAD.ActiveDocument.abortTransaction()
- return
+ if transaction: FreeCAD.ActiveDocument.abortTransaction()
+ return False
- FreeCADGui.doCommand("for obj in j.ViewObject.Proxy.claimChildren():\n"
+ FreeCADGui.doCommand("for obj in f.ViewObject.Proxy.claimChildren():\n"
" obj.ViewObject.hide()")
- FreeCAD.ActiveDocument.commitTransaction()
+ if transaction: FreeCAD.ActiveDocument.commitTransaction()
+ return True
+
+def cmdSliceApart():
+ FreeCAD.ActiveDocument.openTransaction("Slice apart")
+ made = cmdCreateSliceFeature(name= "Slice", mode= "Split", transaction= False)
+
+ if made:
+ FreeCADGui.addModule("CompoundTools.Explode")
+ FreeCADGui.doCommand("CompoundTools.Explode.explodeCompound(f)")
+ FreeCADGui.doCommand("f.ViewObject.hide()")
+ FreeCAD.ActiveDocument.commitTransaction()
+ FreeCADGui.doCommand("App.ActiveDocument.recompute()")
+ else:
+ FreeCAD.ActiveDocument.abortTransaction()
+
class CommandSlice:
"Command to create Slice feature"
def GetResources(self):
return {'Pixmap' : getIconPath("Part_Slice.svg"),
- 'MenuText': QtCore.QT_TRANSLATE_NOOP("Part_SplitFeatures","Slice"),
+ 'MenuText': QtCore.QT_TRANSLATE_NOOP("Part_SplitFeatures","Slice to compound"),
'Accel': "",
- 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Part_SplitFeatures","Part_Slice: split object by intersections with other objects")}
+ 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Part_SplitFeatures","Part_Slice: split object by intersections with other objects, and pack the pieces into a compound.")}
def Activated(self):
if len(FreeCADGui.Selection.getSelectionEx()) > 1 :
@@ -312,6 +327,30 @@ class CommandSlice:
else:
return False
+class CommandSliceApart:
+ "Command to create exploded Slice feature"
+ def GetResources(self):
+ return {'Pixmap' : getIconPath("Part_SliceApart.svg"),
+ 'MenuText': QtCore.QT_TRANSLATE_NOOP("Part_SplitFeatures","Slice apart"),
+ 'Accel': "",
+ 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Part_SplitFeatures","Part_SliceApart: split object by intersections with other objects.")}
+
+ def Activated(self):
+ if len(FreeCADGui.Selection.getSelectionEx()) > 1 :
+ cmdSliceApart()
+ else:
+ mb = QtGui.QMessageBox()
+ mb.setIcon(mb.Icon.Warning)
+ mb.setText(_translate("Part_SplitFeatures", "Select at least two objects, first! First one is the object to be sliced; the rest are objects to slice with.", None))
+ mb.setWindowTitle(_translate("Part_SplitFeatures","Bad selection", None))
+ mb.exec_()
+
+ def IsActive(self):
+ if FreeCAD.ActiveDocument:
+ return True
+ else:
+ return False
+
# -------------------------- /Slice --------------------------------------------------
# -------------------------- XOR --------------------------------------------------
@@ -451,4 +490,5 @@ class CommandXOR:
def addCommands():
FreeCADGui.addCommand('Part_BooleanFragments',CommandBooleanFragments())
FreeCADGui.addCommand('Part_Slice',CommandSlice())
+ FreeCADGui.addCommand('Part_SliceApart',CommandSliceApart())
FreeCADGui.addCommand('Part_XOR',CommandXOR())
diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp
index 7570db7eb9..1fd7f11bf5 100644
--- a/src/Mod/Part/Gui/Command.cpp
+++ b/src/Mod/Part/Gui/Command.cpp
@@ -671,8 +671,10 @@ void CmdPartCompSplitFeatures::activated(int iMsg)
if (iMsg==0)
rcCmdMgr.runCommandByName("Part_BooleanFragments");
else if (iMsg==1)
- rcCmdMgr.runCommandByName("Part_Slice");
+ rcCmdMgr.runCommandByName("Part_SliceApart");
else if (iMsg==2)
+ rcCmdMgr.runCommandByName("Part_Slice");
+ else if (iMsg==3)
rcCmdMgr.runCommandByName("Part_XOR");
else
return;
@@ -695,9 +697,11 @@ Gui::Action * CmdPartCompSplitFeatures::createAction(void)
QAction* cmd0 = pcAction->addAction(QString());
cmd0->setIcon(Gui::BitmapFactory().pixmap("Part_BooleanFragments"));
QAction* cmd1 = pcAction->addAction(QString());
- cmd1->setIcon(Gui::BitmapFactory().pixmap("Part_Slice"));
+ cmd1->setIcon(Gui::BitmapFactory().pixmap("Part_SliceApart"));
QAction* cmd2 = pcAction->addAction(QString());
- cmd2->setIcon(Gui::BitmapFactory().pixmap("Part_XOR"));
+ cmd2->setIcon(Gui::BitmapFactory().pixmap("Part_Slice"));
+ QAction* cmd3 = pcAction->addAction(QString());
+ cmd3->setIcon(Gui::BitmapFactory().pixmap("Part_XOR"));
_pcAction = pcAction;
languageChange();
@@ -729,9 +733,17 @@ void CmdPartCompSplitFeatures::languageChange()
cmd0->setStatusTip(QApplication::translate("Part_SplitFeatures", splitBoolFragments->getStatusTip()));
}
+ Gui::Command* splitSliceApart = rcCmdMgr.getCommandByName("Part_SliceApart");
+ if (splitSliceApart) {
+ QAction* cmd1 = a[1];
+ cmd1->setText(QApplication::translate("Part_SplitFeatures", splitSliceApart->getMenuText()));
+ cmd1->setToolTip(QApplication::translate("Part_SplitFeatures", splitSliceApart->getToolTipText()));
+ cmd1->setStatusTip(QApplication::translate("Part_SplitFeatures", splitSliceApart->getStatusTip()));
+ }
+
Gui::Command* splitSlice = rcCmdMgr.getCommandByName("Part_Slice");
if (splitSlice) {
- QAction* cmd1 = a[1];
+ QAction* cmd1 = a[2];
cmd1->setText(QApplication::translate("Part_SplitFeatures", splitSlice->getMenuText()));
cmd1->setToolTip(QApplication::translate("Part_SplitFeatures", splitSlice->getToolTipText()));
cmd1->setStatusTip(QApplication::translate("Part_SplitFeatures", splitSlice->getStatusTip()));
@@ -739,7 +751,7 @@ void CmdPartCompSplitFeatures::languageChange()
Gui::Command* splitXOR = rcCmdMgr.getCommandByName("Part_XOR");
if (splitXOR) {
- QAction* cmd2 = a[2];
+ QAction* cmd2 = a[3];
cmd2->setText(QApplication::translate("Part_SplitFeatures", splitXOR->getMenuText()));
cmd2->setToolTip(QApplication::translate("Part_SplitFeatures", splitXOR->getToolTipText()));
cmd2->setStatusTip(QApplication::translate("Part_SplitFeatures", splitXOR->getStatusTip()));
diff --git a/src/Mod/Part/Gui/Resources/Part.qrc b/src/Mod/Part/Gui/Resources/Part.qrc
index 462d1b8199..5a45299741 100644
--- a/src/Mod/Part/Gui/Resources/Part.qrc
+++ b/src/Mod/Part/Gui/Resources/Part.qrc
@@ -34,6 +34,7 @@
icons/Part_Shapebuilder.png
icons/Part_ShapeInfo.svg
icons/Part_Slice.svg
+ icons/Part_SliceApart.svg
icons/Part_Sphere.svg
icons/Part_Sweep.svg
icons/Part_Thickness.svg
diff --git a/src/Mod/Part/Gui/Resources/icons/Part_SliceApart.svg b/src/Mod/Part/Gui/Resources/icons/Part_SliceApart.svg
new file mode 100644
index 0000000000..d2e5a6c3b4
--- /dev/null
+++ b/src/Mod/Part/Gui/Resources/icons/Part_SliceApart.svg
@@ -0,0 +1,362 @@
+
+
+
+