当前位置: 首页>>代码示例>>Python>>正文


Python PathPreferences.setDefaultStockTemplate方法代码示例

本文整理汇总了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('')
开发者ID:,项目名称:,代码行数:36,代码来源:


注:本文中的PathScripts.PathPreferences.PathPreferences.setDefaultStockTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。