예제 #1
0
def bottom_hull(p, height=0.001):
    shape = None
    for item in p:
        proj = sl.projection()(p)
        t_shape = sl.linear_extrude(height=height, twist=0, convexity=0, center=True)(
            proj
        )
        t_shape = sl.translate([0, 0, height / 2 - 10])(t_shape)
        if shape is None:
            shape = t_shape
        shape = sl.hull()(p, shape, t_shape)
    return shape
예제 #2
0
def planar_slice(mesh, slice_args, slice_width=5):
    """
    Returns a 2D projection of where the mesh intersects the plane.

    Args:
        mesh (PolyMesh): 3D PolyMesh object to be sliced
        plane (PolyLine): a 3D PolyLine of coplanar points
    """
    (plane, offset) = slice_args
    slice_gen = sl.linear_extrude(slice_width)(plane.get_generator())
    slice_gen = sl.translate(offset)(slice_gen)
    slice = PolyMesh(generator=slice_gen)
    intersection = (slice.intersected(mesh)).get_generator()
    return PolyLine(generator=sl.projection()(intersection))
예제 #3
0
def planar_slice(mesh, slice_args, slice_width=5):
    """
    Returns a 2D projection of where the mesh intersects the plane.

    Args:
        mesh (PolyMesh): 3D PolyMesh object to be sliced
        plane (PolyLine): a 3D PolyLine of coplanar points
    """
    (plane, offset) = slice_args
    slice_gen = sl.linear_extrude(slice_width)(plane.get_generator())
    slice_gen = sl.translate(offset)(slice_gen)
    slice = PolyMesh(generator=slice_gen)
    intersection = (slice.intersected(mesh)).get_generator()
    return PolyLine(generator=sl.projection()(intersection))
예제 #4
0
def baseplate():
    shape = sl.union()(
        case_walls(),
        teensy_holder(),
        # rj9_holder(),
        screw_insert_outers(),
    )

    tool = sl.translate([0, 0, -10])(screw_insert_screw_holes())

    shape = shape - tool

    shape = sl.translate([0, 0, -0.1])(shape)

    return sl.projection(cut=True)(shape)
예제 #5
0
    def save_layouts(self):
        """Return layouts for making this sculpture.

        Returns:
          cut_layout: 2D Layout for laser cutting base
          print_layout: 3D Layout for 3D printing connectors
        """
        links = self.elts
        pls = []
        for link in links:
            if link.name == "coupler" or link.name == "torso":
                #save as stl
                link.elts[0].elts[0].save("%s.stl" % (link.name))
            elif "coupler" not in link.name:
                #create 2D outline
                pm = link.elts[0].elts[0]
                base = pm.get_generator()
                pl = PolyLine(generator=solid.projection()(base))
                pls.append(pl)
        save_layout(pls, "linkages")
예제 #6
0
파일: main.py 프로젝트: jaywreddy/spiderpig
    def save_layouts(self):
        """Return layouts for making this sculpture.

        Returns:
          cut_layout: 2D Layout for laser cutting base
          print_layout: 3D Layout for 3D printing connectors
        """
        links = self.elts
        pls = []
        for link in links:
            if link.name == "coupler" or link.name == "torso":
                #save as stl
                link.elts[0].elts[0].save("%s.stl"%(link.name))
            elif "coupler" not in link.name:
                #create 2D outline
                pm= link.elts[0].elts[0]
                base = pm.get_generator()
                pl = PolyLine(generator=solid.projection()(base) )
                pls.append(pl)
        save_layout(pls, "linkages")
예제 #7
0
def arc(radius):
  a = solid.difference()(
    solid.cylinder(r=radius, h=thick, segments=48), solid.cylinder(r=radius-width, h=thick, segments=48))
  a = solid.intersection()(a, solid.cube([radius, radius, thick]))

  a = solid.difference()(a, 
    solid.translate(v=[.75*outerD, radius-width/2, 0])
      (solid.cylinder(r=bolt/2, h=2*thick, segments=20, center=True)))
  a = solid.difference()(a, 
    solid.translate(v=[radius-width/2, .75*outerD, width/2.0])
      (solid.cylinder(r=bolt/2, h=2*thick, segments=20, center=True)))
  c = solid.translate(v=[radius-width/2, 0, 0])\
    (solid.cylinder(r=bolt/2, h=2*thick, segments=20, center=True))

  # Add bolt holes for fastening the two sheets of acryllic together
  for step in range(1,3):
    a = solid.difference()(a, solid.rotate(a = [0,0, step * 30])(c))

  PolyLine(generator = solid.projection()(a)).save("heliodon/a" + str(radius) + ".dxf")
  return PolyMesh(generator=a)
예제 #8
0
def rationalize_planar_solids(solids, tf_xyz_rpy, offset):
    """
    Args:
      List of solids modified for joinery
    Returns:
      List of PolyLines projected from solids, offset for laser kerf
    """
    final_list = []
    # reverse the transformation, then call layout
    for (p, r) in zip(solids, tf_xyz_rpy):
        translation, rotation = r
        # create reverse
        translation *= -1
        rotation *= -1
        solid_p = p.get_generator()
        translated_p = sl.translate(translation)(solid_p)
        rotated_p = sl.rotate(rotation)(translated_p)
        p_2d = sl.projection(rotated_p)
        polyline = PolyLine(generator=p_2d)
        offset = offset_polygon(polyline, solid)
        final_list.append(offset)
    return final_list
예제 #9
0
def rationalize_planar_solids(solids, tf_xyz_rpy, offset):
    """
    Args:
      List of solids modified for joinery
    Returns:
      List of PolyLines projected from solids, offset for laser kerf
    """
    final_list = []
    #reverse the transformation, then call layout
    for (p, r) in zip(solids, tf_xyz_rpy):
        translation, rotation = r
        #create reverse
        translation *= -1
        rotation *= -1
        solid_p = p.get_generator()
        translated_p = sl.translate(translation)(solid_p)
        rotated_p = sl.rotate(rotation)(translated_p)
        p_2d = sl.projection(rotated_p)
        polyline = PolyLine(generator=p_2d)
        offset = offset_polygon(polyline, solid)
        final_list.append(offset)
    return final_list