From 32ac8929bcc254dbc4203fcca12cf8e353d32e48 Mon Sep 17 00:00:00 2001 From: Adam Spontarelli Date: Sun, 19 Apr 2020 09:00:30 -0400 Subject: [PATCH] Added radio button that links the movement of stock and model when using the set x, y, or z to 0 in Path workbench --- src/Mod/Path/Gui/Resources/panels/PathEdit.ui | 7 +++++++ src/Mod/Path/PathScripts/PathJobGui.py | 19 +++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Mod/Path/Gui/Resources/panels/PathEdit.ui b/src/Mod/Path/Gui/Resources/panels/PathEdit.ui index 4c768a4c5be7..8043ad4e9a7b 100644 --- a/src/Mod/Path/Gui/Resources/panels/PathEdit.ui +++ b/src/Mod/Path/Gui/Resources/panels/PathEdit.ui @@ -718,6 +718,13 @@ + + + + Link Stock and Model + + + diff --git a/src/Mod/Path/PathScripts/PathJobGui.py b/src/Mod/Path/PathScripts/PathJobGui.py index 0b033cc4a9a0..a2371ed8addb 100644 --- a/src/Mod/Path/PathScripts/PathJobGui.py +++ b/src/Mod/Path/PathScripts/PathJobGui.py @@ -404,6 +404,7 @@ def setupUi(self, obj): self.form.stockExtXpos.textChanged.connect(self.checkXpos) self.form.stockExtYpos.textChanged.connect(self.checkYpos) self.form.stockExtZpos.textChanged.connect(self.checkZpos) + self.form.linkStockAndModel.setChecked(True) def checkXpos(self): self.trackXpos = self.form.stockExtXneg.text() == self.form.stockExtXpos.text() @@ -970,15 +971,25 @@ def restoreSelection(self, selection): def modelSet0(self, axis): with selectionEx() as selection: for sel in selection: - model = sel.Object + selObject = sel.Object for name in sel.SubElementNames: - feature = model.Shape.getElement(name) + feature = selObject.Shape.getElement(name) bb = feature.BoundBox offset = FreeCAD.Vector(axis.x * bb.XMax, axis.y * bb.YMax, axis.z * bb.ZMax) PathLog.track(feature.BoundBox.ZMax, offset) - p = model.Placement + p = selObject.Placement p.move(offset) - model.Placement = p + selObject.Placement = p + + if self.form.linkStockAndModel.isChecked(): + # Also move the objects not selected + # if selection is not model, move the model too + # if the selection is not stock and there is a stock, move the stock too + for model in self.obj.Model.Group: + if model != selObject: + Draft.move(model, offset) + if selObject != self.obj.Stock and self.obj.Stock: + Draft.move(self.obj.Stock, offset) def modelMove(self, axis): scale = self.form.modelMoveValue.value()