From 61de21bfbbd0c2f062955281f2cfd7c16bdbb610 Mon Sep 17 00:00:00 2001 From: JeromeL63 Date: Thu, 7 Nov 2019 19:04:19 +0100 Subject: [PATCH] Added Linecut function --- src/Mod/Arch/ArchCutPlane.py | 53 ++- src/Mod/Arch/Resources/icons/Arch_CutLine.svg | 418 ++++++++++++++++++ 2 files changed, 466 insertions(+), 5 deletions(-) create mode 100644 src/Mod/Arch/Resources/icons/Arch_CutLine.svg diff --git a/src/Mod/Arch/ArchCutPlane.py b/src/Mod/Arch/ArchCutPlane.py index 90d2cedf23..15d86a0c55 100644 --- a/src/Mod/Arch/ArchCutPlane.py +++ b/src/Mod/Arch/ArchCutPlane.py @@ -1,7 +1,8 @@ #*************************************************************************** #* * #* Copyright (c) 2014 * -#* Jonathan Wiedemann * +#* Jonathan Wiedemann (cutplan) * +#* Jerome Laverroux 1 + + def Activated(self): + sel = FreeCADGui.Selection.getSelectionEx() + if len(sel) != 2: + FreeCAD.Console.PrintError("You must select exactly two objects, the shape to be cut and a line\n") + return + if not sel[1].SubObjects: + FreeCAD.Console.PrintError("You must select a line from the second object (cut line), not the whole object\n") + return + panel=_CutPlaneTaskPanel(linecut=True) + FreeCADGui.Control.showDialog(panel) + class _CommandCutPlane: "the Arch CutPlane command definition" def GetResources(self): @@ -85,7 +117,14 @@ class _CommandCutPlane: FreeCADGui.Control.showDialog(panel) class _CutPlaneTaskPanel: - def __init__(self): + def __init__(self,linecut=False): + self.linecut=linecut + self.plan=None + if linecut: + self.plan=plan=getPlanWithLine(FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0]) + else : + self.plan = FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0] + self.form = QtGui.QWidget() self.form.setObjectName("TaskPanel") self.grid = QtGui.QGridLayout(self.form) @@ -113,7 +152,10 @@ class _CutPlaneTaskPanel: if s[1].SubObjects: FreeCAD.ActiveDocument.openTransaction(translate("Arch","Cutting")) FreeCADGui.addModule("Arch") - FreeCADGui.doCommand("Arch.cutComponentwithPlane(FreeCADGui.Selection.getSelectionEx()[0],FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0],"+ str(val) +")") + ###TODO redo FreeCADGui.doCommand by using self.plan: + #FreeCADGui.doCommand("Arch.cutComponentwithPlane(FreeCADGui.Selection.getSelectionEx()[0],self.plan,"+ str(val) +")") + cutComponentwithPlane(FreeCADGui.Selection.getSelectionEx()[0],self.plan,val) + FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return True @@ -129,7 +171,7 @@ class _CutPlaneTaskPanel: return int(QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Cancel) def previewCutVolume(self, i): - cutVolume = ArchCommands.getCutVolume(FreeCADGui.Selection.getSelectionEx()[1].SubObjects[0], FreeCADGui.Selection.getSelectionEx()[0].Object.Shape) + cutVolume = ArchCommands.getCutVolume(self.plan,FreeCADGui.Selection.getSelectionEx()[0].Object.Shape) FreeCAD.ActiveDocument.removeObject(self.previewObj.Name) self.previewObj = FreeCAD.ActiveDocument.addObject("Part::Feature", "PreviewCutVolume") self.previewObj.ViewObject.ShapeColor = (1.00,0.00,0.00) @@ -150,3 +192,4 @@ class _CutPlaneTaskPanel: if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_CutPlane',_CommandCutPlane()) + FreeCADGui.addCommand('Arch_CutLine', _CommandCutLine()) diff --git a/src/Mod/Arch/Resources/icons/Arch_CutLine.svg b/src/Mod/Arch/Resources/icons/Arch_CutLine.svg new file mode 100644 index 0000000000..c651cd105c --- /dev/null +++ b/src/Mod/Arch/Resources/icons/Arch_CutLine.svg @@ -0,0 +1,418 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + [wood galaxy] + + + Arch_CutPlane + 2014-11-11 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/Arch/Resources/icons/Arch_CutPlane.svg + + + FreeCAD LGPL2+ + + + + + [agryson] Alexander Gryson + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +