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


Python Component.no_trim方法代码示例

本文整理汇总了Python中component.Component.no_trim方法的典型用法代码示例。如果您正苦于以下问题:Python Component.no_trim方法的具体用法?Python Component.no_trim怎么用?Python Component.no_trim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在component.Component的用法示例。


在下文中一共展示了Component.no_trim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: writeOpenSCAD

# 需要导入模块: from component import Component [as 别名]
# 或者: from component.Component import no_trim [as 别名]
def writeOpenSCAD(script, components={}, object_body='', deflated='',
                  full_body='', top='', boss=None, bosses=[], topbot='',
                  debug=False):
  '''
  This horrifying function actually puts together the scripts necessary to do
  the openSCAD operations that Makers' Marks relies on. It can write scripts
  for deforming shells, checking intersections, and more, based on the
  script name passed in. It's bad, though.
  '''
  text = 'union() {\n'

  if script == DEFORM_SHELL_SCRIPT:
    text += '''
  difference() {
    import("%(obj_body)s");
    %(solid_bb_clearance)s
  }
    ''' % {
    'obj_body':object_body,
    'solid_bb_clearance':placeBoundingBoxSCAD(components, geom='bbsolid')
  } #subtracts translated solid bounding box from body

    text += '''
    difference() {
     rotate([180,0,0])translate([0,0,7.5])%(shelled_bb)s
      import("%(solid_obj_body)s");
       }
    ''' % {
    'shelled_bb':placeBoundingBoxSCAD(components, geom='bbshell'),
    'solid_obj_body':full_body
  } #subtracts solid body from hollow bounding box


  if script == CHECK_INTERSECT_SCRIPT and object_body == '':
    text += '''
intersection() {
  %(comp_0)s
  %(comp_1)s
}
''' % {
    'comp_0':placeCompOpenSCAD(components[0], geom='clearance'),
    'comp_1':placeCompOpenSCAD(components[1], geom='clearance'),
  }
  if script == CHECK_INTERSECT_SCRIPT and not object_body == '':
    text += '''
intersection() {
  %(comp_0)s
  import("%(obj)s");
}
''' % {
    'comp_0':placeCompOpenSCAD(components[0], geom='clearance'),
    'obj':object_body,
  }

  if script == SUB_COMPONENT_SCRIPT:
    comps_sub = ''
    comps_add = ''
    for component in components:
      if component['type'] == Component.parting_line or component['type'] == Component.parting_line_calculated:
        # these will be dealt with in a special step later
        continue
      comps_sub += placeCompOpenSCAD(component, geom='sub')
      if Component.no_trim(component['type']):
        comps_add += placeCompOpenSCAD(component, geom='add')
      elif component['type'] in pushed_comp:
        comps_add += internalOnlyBoundingBox(placeCompOpenSCAD(component, geom='add'),
                                  full_body, component)
      else:
        comps_add += internalOnly(placeCompOpenSCAD(component, geom='add'),
                                  full_body)
    text += '''
difference() {
\timport("%(obj)s");
// first we need to subtract everything
\t%(comps_sub)s
}
// now we add mounting points back in (they are cut to size of the body)
%(comps_add)s
''' % {
    'obj':object_body,
    'comps_sub':comps_sub,
    'comps_add':comps_add,
  }

  if script == PART_SCRIPT:
    pline = 'cube(1);'
    for comp in components:
      if comp['type'] is Component.parting_line_calculated:
        pline = placePLineOpenSCAD(comp)
        break
    if pline == '':
      print 'wtf? no parting line?'
    if top == True:
      text += '''
difference(){
\timport("%(obj)s");
\t%(pline)s
}
''' % {
    'obj':object_body,
#.........这里部分代码省略.........
开发者ID:valkyriesavage,项目名称:makers-marks,代码行数:103,代码来源:openscad.py


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