def saveStockSettings(self): if self.form.stockGroup.isChecked(): attrs = {} attrs['version'] = 1 typ = [PathStock.StockType.CreateBox, PathStock.StockType.CreateCylinder, PathStock.StockType.FromBase][self.form.stock.currentIndex()] attrs['create'] = typ if typ == PathStock.StockType.CreateBox: attrs['length'] = FreeCAD.Units.Quantity(self.form.stockBoxLength.text()).UserString attrs['width'] = FreeCAD.Units.Quantity(self.form.stockBoxWidth.text()).UserString attrs['height'] = FreeCAD.Units.Quantity(self.form.stockBoxHeight.text()).UserString if typ == PathStock.StockType.CreateCylinder: attrs['radius'] = FreeCAD.Units.Quantity(self.form.stockCylinderRadius.text()).UserString attrs['height'] = FreeCAD.Units.Quantity(self.form.stockCylinderHeight.text()).UserString if typ == PathStock.StockType.FromBase: attrs['xneg'] = FreeCAD.Units.Quantity(self.form.stockExtXneg.text()).UserString attrs['xpos'] = FreeCAD.Units.Quantity(self.form.stockExtXpos.text()).UserString attrs['yneg'] = FreeCAD.Units.Quantity(self.form.stockExtYneg.text()).UserString attrs['ypos'] = FreeCAD.Units.Quantity(self.form.stockExtYpos.text()).UserString attrs['zneg'] = FreeCAD.Units.Quantity(self.form.stockExtZneg.text()).UserString attrs['zpos'] = FreeCAD.Units.Quantity(self.form.stockExtZpos.text()).UserString if self.form.stockPlacementGroup.isChecked(): angle = FreeCAD.Units.Quantity(self.form.stockAngle.text()).Value axis = FreeCAD.Vector(self.form.stockAxisX.value(), self.form.stockAxisY.value(), self.form.stockAxisZ.value()) rot = FreeCAD.Rotation(axis, angle) attrs['rotX'] = rot.Q[0] attrs['rotY'] = rot.Q[1] attrs['rotZ'] = rot.Q[2] attrs['rotW'] = rot.Q[3] attrs['posX'] = FreeCAD.Units.Quantity(self.form.stockPositionX.text()).Value attrs['posY'] = FreeCAD.Units.Quantity(self.form.stockPositionY.text()).Value attrs['posZ'] = FreeCAD.Units.Quantity(self.form.stockPositionZ.text()).Value PathPreferences.setDefaultStockTemplate(json.dumps(attrs)) else: PathPreferences.setDefaultStockTemplate('')
def saveStockSettings(self): if self.form.stockGroup.isChecked(): attrs = {} attrs["version"] = 1 typ = [ PathStock.StockType.CreateBox, PathStock.StockType.CreateCylinder, PathStock.StockType.FromBase, ][self.form.stock.currentIndex()] attrs["create"] = typ if typ == PathStock.StockType.CreateBox: attrs["length"] = FreeCAD.Units.Quantity( self.form.stockBoxLength.text() ).UserString attrs["width"] = FreeCAD.Units.Quantity( self.form.stockBoxWidth.text() ).UserString attrs["height"] = FreeCAD.Units.Quantity( self.form.stockBoxHeight.text() ).UserString if typ == PathStock.StockType.CreateCylinder: attrs["radius"] = FreeCAD.Units.Quantity( self.form.stockCylinderRadius.text() ).UserString attrs["height"] = FreeCAD.Units.Quantity( self.form.stockCylinderHeight.text() ).UserString if typ == PathStock.StockType.FromBase: attrs["xneg"] = FreeCAD.Units.Quantity( self.form.stockExtXneg.text() ).UserString attrs["xpos"] = FreeCAD.Units.Quantity( self.form.stockExtXpos.text() ).UserString attrs["yneg"] = FreeCAD.Units.Quantity( self.form.stockExtYneg.text() ).UserString attrs["ypos"] = FreeCAD.Units.Quantity( self.form.stockExtYpos.text() ).UserString attrs["zneg"] = FreeCAD.Units.Quantity( self.form.stockExtZneg.text() ).UserString attrs["zpos"] = FreeCAD.Units.Quantity( self.form.stockExtZpos.text() ).UserString if self.form.stockPlacementGroup.isChecked(): angle = FreeCAD.Units.Quantity(self.form.stockAngle.text()).Value axis = FreeCAD.Vector( self.form.stockAxisX.value(), self.form.stockAxisY.value(), self.form.stockAxisZ.value(), ) rot = FreeCAD.Rotation(axis, angle) attrs["rotX"] = rot.Q[0] attrs["rotY"] = rot.Q[1] attrs["rotZ"] = rot.Q[2] attrs["rotW"] = rot.Q[3] attrs["posX"] = FreeCAD.Units.Quantity( self.form.stockPositionX.text() ).Value attrs["posY"] = FreeCAD.Units.Quantity( self.form.stockPositionY.text() ).Value attrs["posZ"] = FreeCAD.Units.Quantity( self.form.stockPositionZ.text() ).Value PathPreferences.setDefaultStockTemplate(json.dumps(attrs)) else: PathPreferences.setDefaultStockTemplate("")