Skip to content

Commit

Permalink
Added radio button that links the movement of stock and model when us…
Browse files Browse the repository at this point in the history
…ing the set x, y, or z to 0 in Path workbench
  • Loading branch information
spontarelliam committed Apr 19, 2020
1 parent ba34cc6 commit 32ac892
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/Mod/Path/Gui/Resources/panels/PathEdit.ui
Expand Up @@ -718,6 +718,13 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="linkStockAndModel">
<property name="text">
<string>Link Stock and Model</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
19 changes: 15 additions & 4 deletions src/Mod/Path/PathScripts/PathJobGui.py
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 32ac892

Please sign in to comment.