本文整理汇总了Python中PathScripts.PathPreferences.PathPreferences.setDefaultStockTemplate方法的典型用法代码示例。如果您正苦于以下问题:Python PathPreferences.setDefaultStockTemplate方法的具体用法?Python PathPreferences.setDefaultStockTemplate怎么用?Python PathPreferences.setDefaultStockTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathScripts.PathPreferences.PathPreferences
的用法示例。
在下文中一共展示了PathPreferences.setDefaultStockTemplate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: saveStockSettings
# 需要导入模块: from PathScripts.PathPreferences import PathPreferences [as 别名]
# 或者: from PathScripts.PathPreferences.PathPreferences import setDefaultStockTemplate [as 别名]
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('')