當前位置: 首頁>>代碼示例>>Python>>正文


Python Part.makeBox方法代碼示例

本文整理匯總了Python中Part.makeBox方法的典型用法代碼示例。如果您正苦於以下問題:Python Part.makeBox方法的具體用法?Python Part.makeBox怎麽用?Python Part.makeBox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Part的用法示例。


在下文中一共展示了Part.makeBox方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: execute

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeBox [as 別名]
def execute(self, fp):
    O=FreeCAD.Vector(0,0,0)
    vectL=FreeCAD.Vector(fp.L,0,0)
    vectW=FreeCAD.Vector(0,fp.W,0)
    vectH=FreeCAD.Vector(0,0,fp.H)
    base=[vectL,vectW,vectH]
    outline=[]
    for i in range(3):
      f1=Part.Face(Part.makePolygon([O,base[0],base[0]+base[1],base[1],O]))
      outline.append(f1)
      f2=f1.copy()
      f2.translate(base[2])
      outline.append(f2)
      base.append(base.pop(0))
    box=Part.Solid(Part.Shell(outline))
    tank=box.makeThickness([box.Faces[0],box.Faces[2]],-fp.thk1,1.e-3)
    top=Part.makeBox(fp.L-2*fp.thk1,fp.W-2*fp.thk1,fp.thk2,FreeCAD.Vector(fp.thk1,fp.thk1,fp.H-2*fp.thk2))
    fp.Shape=Part.makeCompound([tank,top]) 
開發者ID:oddtopus,項目名稱:flamingo,代碼行數:20,代碼來源:pipeFeatures.py

示例2: box

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeBox [as 別名]
def box(x, y, z, rounding=None):
    """Create a box, optionally rounding the edges

    Parameters
    ----------
    x, y, z: float
        Size of the box in 3 dimensions
    rounding: float, optional
        If specified, the edges will be rounded with this radius
    """
    box = Part.makeBox(x, y, z)

    centre = FreeCAD.Vector(-0.5*x, -0.5*y, -0.5*z)
    box.Placement.Base = centre

    if rounding is not None:
        box = box.makeFillet(rounding, box.Edges)
    return box


#bar = box(500, 150, 200, 10)
#mesh = freecad_mesh(bar)

#MeshPart.meshFromShape(box,GrowthRate=0.3,SegPerEdge=1,SegPerRadius=2,SecondOrder=0,Optimize=1,AllowQuad=0) 
開發者ID:DavidPowell,項目名稱:OpenModes,代碼行數:26,代碼來源:freecad.py

示例3: check_limit_z

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeBox [as 別名]
def check_limit_z(tab_face, width, pos_y, material_face, material_plane):
    box_x_size = material_plane.thickness / 2.0 # OK
    box_y_size = width / 2.0
    box_z_size = 0.1

    box_z_plus = Part.makeBox(box_x_size, box_y_size, box_z_size)
    box_z_plus.translate(FreeCAD.Vector(0.005, pos_y - box_y_size/2.0, material_face.thickness / 2.0))

    box_z_minus = Part.makeBox(box_x_size, box_y_size, box_z_size)
    box_z_minus.translate(FreeCAD.Vector(0.005, pos_y - box_y_size/2.0, -box_z_size - material_face.thickness / 2.0))

    z_plus_inside, toto1 = check_intersect(box_z_plus, tab_face, material_plane)
    z_minus_inside, toto2 = check_intersect(box_z_minus, tab_face, material_plane)

    #shapeobj = FreeCAD.ActiveDocument.addObject("Part::Feature","tstupdds_plus")
    #shapeobj.Shape = toto1
    #FreeCAD.ActiveDocument.recompute()

    #shapeobj = FreeCAD.ActiveDocument.addObject("Part::Feature","tstupddsd_minus")
    #shapeobj.Shape = toto2
    #FreeCAD.ActiveDocument.recompute()
    #print("z plus %r, minus %r" % (z_plus_inside, z_minus_inside))

    return z_plus_inside, z_minus_inside 
開發者ID:execuc,項目名稱:LCInterlocking,代碼行數:26,代碼來源:helper.py

示例4: check_limit_y

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeBox [as 別名]
def check_limit_y(tab_face, height, pos_y, width, material_plane):
    box_x_size = material_plane.thickness / 2.0 # OK
    box_y_size = 0.1
    box_z_size = height / 2.0

    box_y_minus = Part.makeBox(box_x_size, box_y_size, box_z_size)
    box_y_minus.translate(FreeCAD.Vector(0.005, pos_y - width/2.0 - box_y_size, -box_z_size / 2.0))

    box_y_plus = Part.makeBox(box_x_size, box_y_size, box_z_size)
    box_y_plus.translate(FreeCAD.Vector(0.005, pos_y + width/2.0, -box_z_size / 2.0))

    y_plus_inside, toto1 = check_intersect(box_y_plus, tab_face, material_plane)
    y_minus_inside, toto2 = check_intersect(box_y_minus, tab_face, material_plane)

    #shapeobj = FreeCAD.ActiveDocument.addObject("Part::Feature","y_plus_inside")
    #shapeobj.Shape = toto1
    #FreeCAD.ActiveDocument.recompute()

    #shapeobj = FreeCAD.ActiveDocument.addObject("Part::Feature","y_minus_inside")
    #shapeobj.Shape = toto2
    #FreeCAD.ActiveDocument.recompute()
    #print("y plus %r, minus %r" % (y_plus_inside, y_minus_inside))

    return y_plus_inside, y_minus_inside 
開發者ID:execuc,項目名稱:LCInterlocking,代碼行數:26,代碼來源:helper.py

示例5: check_limit_y_on_for_tab

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeBox [as 別名]
def check_limit_y_on_for_tab(tab_face, height, pos_y, width, thickness, material_face):
    box_x_size = thickness / 2.0 # OK
    box_y_size = 0.1
    box_z_size = height / 2.0

    box_y_minus = Part.makeBox(box_x_size, box_y_size, box_z_size)
    box_y_minus.translate(FreeCAD.Vector(-0.005 - box_x_size, pos_y - width/2.0 - box_y_size, -box_z_size / 2.0))

    box_y_plus = Part.makeBox(box_x_size, box_y_size, box_z_size)
    box_y_plus.translate(FreeCAD.Vector(-0.005 - box_x_size, pos_y + width/2.0, -box_z_size / 2.0))

    y_plus_inside, toto1 = check_intersect(box_y_plus, tab_face, material_face)
    y_minus_inside, toto2 = check_intersect(box_y_minus, tab_face, material_face)

    #shapeobj = FreeCAD.ActiveDocument.addObject("Part::Feature","y_plus_inside")
    #shapeobj.Shape = toto1
    #FreeCAD.ActiveDocument.recompute()

    #shapeobj = FreeCAD.ActiveDocument.addObject("Part::Feature","y_minus_inside")
    #shapeobj.Shape = toto2
    #FreeCAD.ActiveDocument.recompute()
    #print("y plus %r, minus %r" % (y_plus_inside, y_minus_inside))

    return y_plus_inside, y_minus_inside 
開發者ID:execuc,項目名稱:LCInterlocking,代碼行數:26,代碼來源:helper.py

示例6: execute

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeBox [as 別名]
def execute(self, fp):
    '''"Print a short message when doing a recomputation, this method is mandatory" '''
    #fp.Shape = Part.makeBox(1,1,1 + len(fp.diameters))
    origshape = fp.baseObject[0].Shape
    shape = origshape
    for diam in fp.diameters:
      FreeCAD.Console.PrintLog("Generating hole tool for: " + diam + "\n")
      edge, m, f, o, type = cshSplitEdgeDiam(diam)
      cshole = cshMakeCSHole(m, type)
      FastenerBase.FSMoveToObject(cshole, origshape.getElement(edge), f == '1', float(o))
      shape = shape.cut(cshole)
    fp.Shape = shape 
開發者ID:shaise,項目名稱:FreeCAD_FastenersWB,代碼行數:14,代碼來源:CountersunkHoles.py

示例7: makeBox

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeBox [as 別名]
def makeBox(cls, length, width, height, pnt=Vector(0, 0, 0), dir=Vector(0, 0, 1)):
        """
        makeBox(length,width,height,[pnt,dir]) -- Make a box located in pnt with the dimensions (length,width,height)
        By default pnt=Vector(0,0,0) and dir=Vector(0,0,1)'
        """
        return Shape.cast(FreeCADPart.makeBox(length, width, height, pnt.wrapped, dir.wrapped)) 
開發者ID:jmwright,項目名稱:cadquery-freecad-module,代碼行數:8,代碼來源:shapes.py

示例8: create_flat_connection

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeBox [as 別名]
def create_flat_connection(hinge_properties, referentiel_face):
    box_x_size = hinge_properties.arc_length
    box_y_size = hinge_properties.extrustion_vector.Length
    box_z_size = hinge_properties.thickness
    box = Part.makeBox(box_x_size, box_y_size, box_z_size, FreeCAD.Vector(0., -box_y_size/2.0, -box_z_size/2.0))

    flat_connection = transform(box, referentiel_face)

    return flat_connection 
開發者ID:execuc,項目名稱:LCInterlocking,代碼行數:11,代碼來源:makehinges.py

示例9: create_hole_hinge

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeBox [as 別名]
def create_hole_hinge(hinge_clearance, hinge_length, thickness, kerf_diameter):
    height = thickness * 2.0
    hinge_width = max(10e-3, hinge_clearance - kerf_diameter)
    if hinge_clearance < kerf_diameter:
        raise ValueError("Hinge clearance is less than kerf diameter")
    elif hinge_clearance < 2. * kerf_diameter:
        box_length = hinge_length - kerf_diameter
        hinge = Part.makeBox(hinge_width, box_length, height, FreeCAD.Vector(-hinge_width/2.0, -box_length/2.0, -height/2.0))
    else:
        box_length = hinge_length - hinge_width - kerf_diameter # hinge_width is for the two corner radius
        hinge = draw_rounded_hinge(hinge_width, box_length, height)

    return hinge 
開發者ID:execuc,項目名稱:LCInterlocking,代碼行數:15,代碼來源:makehinges.py

示例10: screw_way_on_face

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeBox [as 別名]
def screw_way_on_face(material_face, material_plane, screw_nut_spec, pos_y, dog_bone=False):
    # horizontal hole
    vert_corrected_length = screw_nut_spec.screw_length - material_plane.thickness \
                            + material_plane.thickness_tolerance + screw_nut_spec.screw_length_tol
    corrected_width = screw_nut_spec.screw_diameter * 1.2 - material_face.laser_beam_diameter
    corrected_height = material_face.thickness  # + materialFace.tolerance
    screw_hole = Part.makeBox(vert_corrected_length, corrected_width, corrected_height,
                              FreeCAD.Vector(0.,
                                             -corrected_width / 2.0, -corrected_height / 2.0))
    if dog_bone:
        screw_hole = helper.make_dog_bone_on_limits_on_xy(screw_hole, corrected_height, True)
    x_pos = -vert_corrected_length
    screw_hole.translate(FreeCAD.Vector(x_pos, pos_y, 0))
    # Nut hole
    corrected_length = screw_nut_spec.nut_height - material_face.laser_beam_diameter + 0.1
    corrected_width = screw_nut_spec.nut_flat_flat - material_face.laser_beam_diameter + 0.1
    nut_hole = Part.makeBox(corrected_length, corrected_width, corrected_height,
                            FreeCAD.Vector(0,
                                           -corrected_width / 2.0, -corrected_height / 2.0))
    x_pos = -vert_corrected_length + screw_nut_spec.nut_height + screw_nut_spec.screw_length_tol
    nut_hole.translate(FreeCAD.Vector(x_pos, pos_y, 0))
    if dog_bone:
        nut_hole = helper.make_dog_bone_on_limits_on_xy(nut_hole, corrected_height)
    hole = screw_hole.fuse(nut_hole)
    return hole


#            X (Length)
#            |
#            |
#            |
#            |Z (Height)
#            ---------------------------> Y (Width)
# X est vers le haut
# Y est aligné sur la face
# Z est devant la camera 
開發者ID:execuc,項目名稱:LCInterlocking,代碼行數:38,代碼來源:join.py

示例11: tab_join_create_tab_on_face

# 需要導入模塊: import Part [as 別名]
# 或者: from Part import makeBox [as 別名]
def tab_join_create_tab_on_face(material_face, material_plane, width, pos_y, tab_face, dog_bone=False):

    y_plus_inside, y_minus_inside = helper.check_limit_y_on_for_tab(tab_face, material_face.thickness, pos_y, width,
                                                                    material_plane.thickness, material_face)
    # X Rien pr l'instant, mais on peut prendre en compte l'epaiseur variante de la piece opposé => length
    # Y Ajout d'un Kerf => width
    # Z Rien => height
    corrected_length = material_plane.thickness
    # corrected_width = width + materialFace.laser_beam_diameter
    corrected_height = material_face.thickness

    corrected_width = width  # - materialPlane.laser_beam_diameter
    corrected_width_center = corrected_width / 2.0
    if y_minus_inside and y_plus_inside:
        corrected_width += material_face.laser_beam_diameter
        corrected_width_center = corrected_width / 2.0
    elif y_minus_inside:
        corrected_width += material_face.laser_beam_diameter / 2.0
        corrected_width_center = (corrected_width + material_face.laser_beam_diameter / 2.0) / 2.0
    elif y_plus_inside:
        corrected_width += material_face.laser_beam_diameter / 2.0
        corrected_width_center = (corrected_width - material_face.laser_beam_diameter / 2.0) / 2.0

    #origin = FreeCAD.Vector(-corrected_length / 2.0, -corrected_width_center, -corrected_height / 2.0)
    origin = FreeCAD.Vector(0., -corrected_width_center, -corrected_height / 2.0)
    tab = Part.makeBox(corrected_length, corrected_width, corrected_height, origin)
    tab.translate(FreeCAD.Vector(0, pos_y, 0))

    hole = None
    left_hole = None
    right_hole = None

    if dog_bone:
        radius = min(corrected_width, corrected_length) * 2 / 30.
        if y_minus_inside:
            left_hole = Part.makeCylinder(radius, corrected_height,
                                          FreeCAD.Vector(0, -corrected_width_center + pos_y, -corrected_height / 2.0),
                                          FreeCAD.Vector(0, 0, 1.))
        if y_plus_inside:
            right_hole = Part.makeCylinder(radius, corrected_height,
                                           FreeCAD.Vector(0, -corrected_width_center + corrected_width + pos_y,
                                           -corrected_height / 2.0),
                                           FreeCAD.Vector(0, 0, 1.))
        hole = left_hole
        if hole and right_hole:
            hole = hole.fuse(right_hole)
        elif right_hole:
            hole = right_hole

    return tab, hole 
開發者ID:execuc,項目名稱:LCInterlocking,代碼行數:52,代碼來源:join.py


注:本文中的Part.makeBox方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。