def __init__(self,
                 cone,
                 shoulder=None,
                 thickness=None,
                 threads_per_inch=6,
                 thread_height=None,
                 thread_diameter=None,
                 screw_length=None,
                 screw_diameter=None,
                 screw_size=None):
        super(ScrewInBaseWithScrewHole,
              self).__init__(cone, shoulder, thickness, threads_per_inch,
                             thread_height, thread_diameter)
        radius = to_mm(cone.inner_diameter / 2)

        shoulder = to_mm(self.shoulder)
        thickness = to_mm(self.thickness)
        screw_length = to_mm(screw_length)
        screw_radius = to_mm(screw_diameter / 2)
        if not screw_radius:
            "get_screw_size"

        self.mate = difference()(
            union()(self.mate,
                    down(shoulder)(cylinder(h=screw_length,
                                            r=screw_radius + thickness / 2.)),
                    up(min(screw_length - shoulder - thickness,
                           -thickness))(cylinder(h=thickness, r=radius))),
            down(shoulder)(cylinder(h=screw_length, r=screw_radius)))
    def __init__(self,
                 cone,
                 shoulder=None,
                 thickness=None,
                 threads_per_inch=6,
                 offset=None):
        super(ThreadedBaseOutset, self).__init__(cone, shoulder, thickness)
        shoulder = to_mm(self.shoulder)
        thickness = to_mm(thickness, self.thickness)
        radius = to_mm(cone.inner_diameter / 2.)
        offset = to_mm(offset, to_inch(thickness))
        tooth = to_mm(1. / threads_per_inch * sqrt(3) / 2.)

        self.cone = union()(
            (cone.cone - cylinder(h=offset, r=3 * radius)), down(shoulder)(
                self.threaded_male_column(length=shoulder + offset,
                                          diameter=radius * 2 - thickness * 2,
                                          threads_per_inch=threads_per_inch)),
            self.slice(cone.cone, thickness,
                       offset=offset)) - down(shoulder - thickness)(cylinder(
                           h=shoulder + offset, r=radius - thickness - tooth))

        self.mate = down(shoulder)(cylinder(h=shoulder, r=radius)) + self.slice(cone.cone, offset) \
                    - down(shoulder)(
            self.threaded_female_column(length=shoulder + offset, diameter=radius * 2 - thickness * 2,
                                        threads_per_inch=threads_per_inch))
    def __init__(self,
                 cone,
                 shoulder=None,
                 thickness=None,
                 cutout_width=None,
                 cutout_length=None):
        super(HollowBaseCutout, self).__init__(cone, shoulder, thickness)

        cutout_width = to_mm(cutout_width, cone.inner_diameter * 0.3)
        cutout_length = to_mm(cutout_length, self.shoulder / 2.0)
        self.cutout_width = to_inch(cutout_width)
        self.cutout_length = to_inch(cutout_length)
        radius = to_mm(cone.inner_diameter / 2.)
        shoulder = to_mm(self.shoulder)
        thickness = to_mm(self.thickness)

        chord = sqrt(radius * radius - (radius - cutout_width**2))

        self.cone = difference()(union()(self.cone, difference()(
            down(shoulder - cutout_length)(cylinder(h=thickness, r=radius)),
            translate([-radius, -radius, -shoulder + cutout_length])(cube([
                radius * 2 - cutout_width - thickness, 2 * radius,
                cutout_length
            ]))), intersection()(translate(
                [radius - cutout_width - thickness, -chord,
                 -shoulder])(cube([thickness, chord * 2, cutout_length])),
                                 down(shoulder)(cylinder(h=shoulder,
                                                         r=radius)))),
                                 translate([
                                     radius - cutout_width, -radius,
                                     -shoulder - 1
                                 ])(cube([
                                     cutout_width, 2 * radius,
                                     cutout_length + 1
                                 ])))
    def __init__(self,
                 cone,
                 shoulder=None,
                 thickness=None,
                 threads_per_inch=6):
        super(ThreadedBaseFlat, self).__init__(cone, shoulder, thickness)
        shoulder = to_mm(self.shoulder)
        thickness = to_mm(self.thickness)
        radius = to_mm(cone.inner_diameter / 2.)
        tooth = to_mm(1. / threads_per_inch * sqrt(3) / 2.)

        self.cone = cone.cone + self.slice(cone.cone, thickness) + down(shoulder)(
            self.threaded_male_column(length=shoulder,
                                      diameter=radius * 2 - thickness * 2,
                                      threads_per_inch=threads_per_inch)) \
                    - down(shoulder - thickness)(cylinder(h=shoulder + thickness, r=radius - thickness - tooth))
        self.mate = down(shoulder)(cylinder(h=shoulder, r=radius)) \
                    - down(shoulder)(
            self.threaded_female_column(length=shoulder + thickness, diameter=radius * 2 - thickness * 2,
                                        threads_per_inch=threads_per_inch))
        sectioner = down(shoulder + self.epsilon)(cylinder(
            h=shoulder + self.epsilon, r=radius)) + cylinder(
                h=thickness / 2,
                r=radius - thickness - thickness / 2. - tooth) + cylinder(
                    h=thickness, r=radius - thickness - thickness - tooth)
        self.cone_section1 = self.cone - sectioner
        self.cone_section2 = self.cone * sectioner
Example #5
0
 def __init__(self, cone, offset, radius, cone_diameter, cone_length):
     super(RamJetNoseCone, self).__init__(cone, offset, radius)
     offset = to_mm(offset)
     radius = to_mm(radius)
     cone_radius = to_mm(cone_diameter / 2.)
     cone_length = to_mm(cone_length)
     self.cone = self.cone + up(offset)(cylinder(
         h=cone_length, r1=cone_radius, r2=0))
     """
    def fittest(self, thickness=3 / 64., width=0):
        thickness = to_mm(thickness)
        width = to_mm(width)
        outer_radius = to_mm(self.outer_diameter / 2.)
        inner_radius = to_mm(self.inner_diameter / 2.)

        test = up(thickness)(cylinder(h=thickness, r=inner_radius)) + cylinder(
            h=thickness, r=outer_radius)
        if width:
            test -= cylinder(h=thickness * 2, r=outer_radius - width)
        return test
Example #7
0
 def __init__(self, cone, offset, radius):
     super(DerivativeNoseCone,
           self).__init__(length=cone.length,
                          thickness=cone.thickness,
                          outer_diameter=cone.outer_diameter,
                          inner_diameter=cone.inner_diameter)
     offset = to_mm(offset)
     radius = to_mm(radius)
     self.cone = cone.cone - up(offset + radius)(sphere(r=radius))
     if self.thickness:
         thickness = to_mm(self.thickness)
         self.cone = self.cone + hull()(cone.cone) * up(offset + radius)(
             sphere(r=radius + thickness) - sphere(r=radius))
    def __init__(self,
                 cone,
                 shoulder=None,
                 thickness=None,
                 upper_tpi=6,
                 lower_tpi=4,
                 offset=None,
                 thread_height=None,
                 thread_diameter=None):
        super(ThreadedBaseOutsetScrewInBase,
              self).__init__(cone, shoulder, thickness)
        shoulder = to_mm(self.shoulder)
        thickness = to_mm(thickness, self.thickness)
        radius = to_mm(cone.inner_diameter / 2.)
        offset = to_mm(offset, to_inch(thickness))
        upper_tooth = to_mm(1. / upper_tpi * sqrt(3) / 2.)
        lower_tooth = to_mm(1. / lower_tpi * sqrt(3) / 2.)
        thread_height = to_mm(thread_height, self.length / 3)
        thread_diameter = to_mm(thread_diameter, cone.inner_diameter / 2.)

        self.cone = difference()(
            union()((cone.cone - cylinder(h=offset, r=3 * radius)),
                    color("red")(self.slice(cone.cone,
                                            thread_height, offset))),
            up(offset - self.epsilon)(self.threaded_female_column(
                length=thread_height + 2 * self.epsilon,
                diameter=thread_diameter,
                threads_per_inch=upper_tpi)),
            cylinder(h=to_mm(0.25), r=radius - thickness))

        core_radius = min(thread_diameter / 2 - thickness - upper_tooth,
                          radius - thickness - lower_tooth)
        lower_thread = down(shoulder)(self.threaded_male_column(
            length=shoulder + offset,
            diameter=radius * 2 - thickness * 2.,
            threads_per_inch=lower_tpi))
        upper_thread = up(offset)(self.threaded_male_column(
            length=thread_height,
            diameter=thread_diameter,
            threads_per_inch=upper_tpi))
        self.center_mate = upper_thread + lower_thread + cylinder(
            h=thickness, r=radius - thickness) - down(shoulder - thickness)(
                cylinder(h=shoulder + offset + thread_height, r=core_radius))

        self.mate = difference()(
            down(shoulder)(cylinder(h=shoulder, r=radius)) +
            self.slice(cone.cone, offset),
            down(shoulder)(self.threaded_female_column(
                length=shoulder + offset,
                diameter=radius * 2 - thickness * 2,
                threads_per_inch=lower_tpi)),
            cylinder(h=thickness, r=radius - thickness))
    def __init__(self, length, polygon, thickness=None, **kwargs):
        """

        :param length: Nosecone length
        :param polygon: Convex polygon
        :param thickness: Nosecone wall thickness
        :param kwargs:
        """
        super(MorphedNoseCone, self).__init__(length, thickness, **kwargs)

        def _solid_nose(length, radius, ratio=1):
            return hull()(self._flatten(cylinder(h=self.epsilon, r=radius)) + up(length)(
                scale(ratio)(self._flatten(linear_extrude()(polygon)))))

        length = to_mm(self.length)
        radius = to_mm(self.outer_diameter / 2.)
        self.cone = _solid_nose(length, radius)
        if self.thickness:
            thickness = to_mm(self.thickness)
            ratio = (radius - thickness) / radius
            self.cone -= _solid_nose(length - thickness, radius - thickness, ratio)
    def __init__(self,
                 cone,
                 shoulder=None,
                 thickness=None,
                 threads_per_inch=6,
                 thread_height=None,
                 thread_diameter=None):
        super(ScrewInBase, self).__init__(cone, shoulder, thickness)
        shoulder = to_mm(self.shoulder)
        thickness = to_mm(thickness, self.thickness)
        radius = to_mm(cone.inner_diameter / 2.)
        thread_height = to_mm(thread_height, self.length / 3)
        thread_diameter = to_mm(thread_diameter, cone.inner_diameter / 2.)
        tooth = to_mm(1. / threads_per_inch * sqrt(3) / 2.)

        self.cone = (cone.cone + self.slice(
            cone.cone, thread_height)) - self.threaded_female_column(
                length=thread_height,
                diameter=thread_diameter,
                threads_per_inch=threads_per_inch)

        self.mate = union()(
            down(shoulder)(cylinder(h=shoulder, r=radius)) -
            down(shoulder - thickness)
            (cylinder(h=shoulder - thickness * 2, r=radius - thickness)),
            self.threaded_male_column(
                length=thread_height,
                diameter=thread_diameter,
                threads_per_inch=threads_per_inch)) - down(thickness)(cylinder(
                    h=thread_height + thickness,
                    r=thread_diameter / 2 - thickness - tooth))
    def __init__(self,
                 cone,
                 shoulder=None,
                 thickness=None,
                 ring_radius=None,
                 ring_thickness=None):
        super(BaseWithRing, self).__init__(cone, shoulder, thickness)
        if not isinstance(cone, SolidBaseCutout) and not isinstance(
                cone, HollowBaseCutout):
            raise "Not designed"

        cutout_length = cone.cutout_length * MM2IN
        cutout_width = cone.cutout_width * MM2IN
        shoulder = cone.shoulder * MM2IN
        thickness = self.thickness * MM2IN
        ring_radius = to_mm(ring_radius, self.thickness)
        ring_thickness = to_mm(ring_thickness, self.thickness / 2.)
        radius = cone.inner_diameter * MM2IN / 2
        self.cone = cone.cone + translate([
            radius - cutout_width + ring_radius - ring_thickness, 0,
            -shoulder + 4 * ring_thickness + 2 * ring_radius
        ])(self._donut(ring_thickness, ring_radius))
Example #12
0
 def __init__(self, cone_class, taper_diameter, taper_length, flat_length,
              **kwargs):
     super(DerivativeNoseCone, self).__init__(**kwargs)
     length = kwargs.pop('length')
     cone = cone_class(outer_diameter=taper_diameter,
                       length=length - taper_length - flat_length,
                       **kwargs)
     flat_length = to_mm(flat_length)
     taper_length = to_mm(taper_length)
     outer_radius = to_mm(self.outer_diameter / 2.0)
     taper_radius = to_mm(taper_diameter / 2.0)
     flat = (cylinder(r=taper_radius, h=flat_length))
     print(cone.outer_diameter)
     taper = cylinder(r1=outer_radius, r2=taper_radius, h=taper_length)
     if self.thickness:
         thickness = to_mm(self.thickness)
         flat -= (cylinder(r=taper_radius - thickness, h=flat_length))
         taper -= cylinder(r1=outer_radius - thickness,
                           r2=taper_radius - thickness,
                           h=taper_length)
     print(taper_radius, outer_radius)
     self.cone = up(taper_length)(flat) + taper + up(taper_length +
                                                     flat_length)(cone.cone)
    def __init__(self,
                 cone,
                 shoulder=None,
                 thickness=None,
                 threads_per_inch=6):
        super(ThreadedBaseInset, self).__init__(cone, shoulder, thickness)
        shoulder = to_mm(self.shoulder)
        thickness = to_mm(self.thickness)
        radius = to_mm(cone.inner_diameter / 2.)
        tooth = to_mm(1. / threads_per_inch * sqrt(3) / 2.)

        self.cone = difference()(
            union()(cone.cone, down(thickness)(cylinder(h=thickness,
                                                        r=radius)),
                    down(shoulder)(self.threaded_male_column(
                        length=shoulder,
                        diameter=radius * 2 - thickness * 2,
                        threads_per_inch=threads_per_inch))),
            down(shoulder - thickness)(cylinder(h=shoulder,
                                                r=radius - thickness - tooth)))
        self.mate = down(shoulder)(cylinder(h=shoulder - thickness, r=radius)) \
                    - down(shoulder)(self.threaded_female_column(length=shoulder, diameter=radius * 2 - thickness * 2,
                                                                 threads_per_inch=threads_per_inch))
    def __init__(self,
                 cone,
                 shoulder=None,
                 thickness=None,
                 elbow_radius=None,
                 bend_radius=None):
        super(BaseWithElbow, self).__init__(cone, shoulder, thickness)
        if not isinstance(cone, SolidBaseCutout) and not isinstance(
                cone, HollowBaseCutout):
            raise "Not designed"

        cutout_length = cone.cutout_length * MM2IN
        cutout_width = cone.cutout_width * MM2IN
        shoulder = cone.shoulder * MM2IN
        thickness = self.thickness * MM2IN
        elbow_radius = to_mm(elbow_radius, self.thickness / 2.)
        bend_radius = to_mm(bend_radius, self.thickness)
        radius = to_mm(cone.inner_diameter / 2.)
        self.cone = union()(cone.cone,
                            translate([radius - cutout_width, 0, -shoulder
                                       ])(self._elbow(elbow_radius,
                                                      bend_radius,
                                                      cutout_width,
                                                      cutout_length)))
    def __init__(self, height, thickness, threads_per_inch, **kwargs):
        height = to_mm(height)
        threads_per_inch = threads_per_inch
        o_d = kwargs.get('outer_diameter', 1)
        i_d = kwargs.get('inner_diameter')

        tooth = to_mm(1. / threads_per_inch * sqrt(3) / 2.)

        if 'bodytube' in kwargs:
            i_d = kwargs['bodytube'].inner_diameter

        if 'inner_bodytube' in kwargs:
            o_d = kwargs['inner_bodytube'].outer_diameter

        i_d -= kwargs.get('fudge_inner', 0.0)
        o_d += kwargs.get('fudge_outer', 0.0)
        if 'fudge' in kwargs:
            i_d -= kwargs.get('fudge')
            o_d += kwargs.get('fudge')

        i_r = to_mm(i_d / 2.)
        o_r = to_mm(o_d / 2.)

        self.male = union()(cylinder(h=height / 2, r=i_r),
                            self.threaded_male_column(
                                height, i_r * 2 - thickness - tooth,
                                threads_per_inch))
        if o_r:
            self.male -= cylinder(h=height, r=o_r)

        self.female = difference()(cylinder(h=height / 2, r=i_r),
                                   self.threaded_female_column(
                                       height, i_r * 2 - thickness - tooth,
                                       threads_per_inch))
        self._o_r = o_r
        self._i_r = i_r
    def __init__(self, length, thickness=None, inner=None, outer=None, points=5, **kwargs):
        """

        :param length:
        :param thickness:
        :param inner:
        :param outer:
        :param points:
        :param kwargs:
        Hollow doesn't work quite right yet.
        """
        super(MorphedNoseCone, self).__init__(length, thickness, **kwargs)
        outer = to_mm(outer, self.outer_diameter / 4.)
        inner = to_mm(inner, self.outer_diameter / 8.)
        out = []
        for i in range(0, points):
            alpha = i * 2. * pi / points
            p = polygon([[0, 0], [inner * cos(alpha - pi / points), inner * sin(alpha - pi / points)],
                         [outer * cos(alpha), outer * sin(alpha)],
                         [inner * cos(alpha + pi / points), inner * sin(alpha + pi / points)]])
            out.append(
                MorphedNoseCone(length, p, inner_diameter=self.inner_diameter, outer_diameter=self.outer_diameter,
                                thickness=thickness).cone)
        self.cone = union()(*out)
    def __init__(self, height, **kwargs):
        bt1 = kwargs.get('bodytube1')
        bt2 = kwargs.get('bodytube2')
        bt3 = kwargs.get('bodytube3')
        fudge = to_mm(kwargs.get('fudge'), default=0.0)
        self.open_end = kwargs.get('open_end', False)
        self.r1 = to_mm(kwargs.get('r1'), safe=True)
        self.r2 = to_mm(kwargs.get('r2'), safe=True)
        self.r3 = to_mm(kwargs.get('r3'), safe=True)
        self.r4 = to_mm(kwargs.get('r4'), safe=True)
        if bt1:
            self.r1 = to_mm(bt1.inner_diameter / 2.0)
            self.r2 = to_mm(bt1.outer_diameter / 2.0)
        if bt2:
            self.r4 = to_mm(bt2.inner_diameter / 2.0)
            self.r3 = to_mm(bt2.outer_diameter / 2.0)
        self.shoulder = to_mm(kwargs.get('shoulder'), default=0.5)
        self.shoulder1 = to_mm(kwargs.get('shoulder1'), safe=True)
        self.shoulder2 = to_mm(kwargs.get('shoulder2'), safe=True)
        self.r1 -= fudge
        self.r4 -= fudge
        if self.shoulder1 is None:
            self.shoulder1 = self.shoulder
        if self.shoulder2 is None:
            self.shoulder2 = self.shoulder
        self.height = to_mm(height)
        self.shoulder = to_mm(0.5)
        self.thickness = to_mm(kwargs.get('thickness'), safe=True)
        self.transition = cylinder(
            h=self.shoulder1, r=self.r1) + up(self.shoulder1 + self.height)(
                cylinder(h=self.shoulder2, r=self.r4)) + up(self.shoulder1)(
                    cylinder(h=self.height, r1=self.r2, r2=self.r3))

        if bt3 and not self.thickness:
            self.transtion -= cylinder(h=shoulder1 + height + shoulder2,
                                       r=bt3.outer_diameter / 2.0)

        if self.thickness:
            subtract = cylinder(
                h=self.shoulder1, r=self.r1 -
                self.thickness) + up(self.shoulder1 + self.height)(cylinder(
                    h=self.shoulder2, r=self.r4 - self.thickness)) + up(
                        self.shoulder1)(cylinder(h=self.height,
                                                 r1=self.r2 - self.thickness,
                                                 r2=self.r3 - self.thickness))
            self.transition -= subtract
            if bt3 or not self.open_end:
                self.transition += cylinder(h=self.thickness, r=self.r1) + up(
                    self.shoulder1 + self.height + self.shoulder2 -
                    self.thickness)(cylinder(h=self.thickness, r=self.r4))
                if bt3:
                    self.transition += cylinder(
                        h=self.shoulder1 + self.height + self.shoulder2,
                        r=to_mm(bt3.outer_diameter / 2.0) + self.thickness)
                    self.transition -= cylinder(
                        h=self.shoulder1 + self.height + self.shoulder2,
                        r=to_mm(bt3.outer_diameter / 2.0) + fudge)
        :param inner:
        :param outer:
        :param points:
        :param kwargs:
        Hollow doesn't work quite right yet.
        """
        super(MorphedNoseCone, self).__init__(length, thickness, **kwargs)
        outer = to_mm(outer, self.outer_diameter / 4.)
        inner = to_mm(inner, self.outer_diameter / 8.)
        out = []
        for i in range(0, points):
            alpha = i * 2. * pi / points
            p = polygon([[0, 0], [inner * cos(alpha - pi / points), inner * sin(alpha - pi / points)],
                         [outer * cos(alpha), outer * sin(alpha)],
                         [inner * cos(alpha + pi / points), inner * sin(alpha + pi / points)]])
            out.append(
                MorphedNoseCone(length, p, inner_diameter=self.inner_diameter, outer_diameter=self.outer_diameter,
                                thickness=thickness).cone)
        self.cone = union()(*out)


if __name__ == '__main__':
    from bodytubes.semroc import bt5

    utils.render_to_file(utils.array(2, to_mm(1), [RectangularNoseCone(0.75, bodytube=bt5, thickness=1 / 16.),
                                                   RectangularNoseCone(0.75, bodytube=bt5, width=.1, depth=.25,
                                                                       thickness=1 / 16.),
                                                   EllipseNoseCone(0.75, bodytube=bt5, thickness=1 / 16.),
                                                   StarNoseCone(0.75, bodytube=bt5, thickness=1 / 16.)]),
                         "examples/morphed_nosecone.scad")
 def __init__(self, length, thickness=None, width=None, depth=None, **kwargs):
     super(MorphedNoseCone, self).__init__(length, thickness, **kwargs)
     width = to_mm(width, sqrt(0.5) * self.outer_diameter)
     depth = to_mm(depth, sqrt(0.5) * self.outer_diameter)
     super(RectangularNoseCone, self).__init__(length, square([width, depth], center=True), thickness, **kwargs)
Example #20
0
    def __init__(self, height, **kwargs):
        bt1 = kwargs.get('bodytube1')
        bt2 = kwargs.get('bodytube2')
        self.r1= to_mm(kwargs.get('r1'),safe=True)
        self.r2= to_mm(kwargs.get('r2'),safe=True)
        self.r3= to_mm(kwargs.get('r3'),safe=True)
        self.r4= to_mm(kwargs.get('r4'),safe=True)
        if bt1:
            self.r1=to_mm(bt1.inner_diameter/2.0)
            self.r2=to_mm(bt1.outer_diameter/2.0)
        if bt2:
            self.r4=to_mm(bt2.inner_diameter/2.0)
            self.r3=to_mm(bt2.outer_diameter/2.0)
        self.shoulder= to_mm(kwargs.get('shoulder'),default=0.5)
        self.shoulder1 = to_mm(kwargs.get('shoulder1'),safe=True)
        self.shoulder2 = to_mm(kwargs.get('shoulder2'),safe=True)
        if self.shoulder1 is None:
            self.shoulder1 = self.shoulder
        if self.shoulder2 is None:
            self.shoulder2 = self.shoulder
        self.height = to_mm(height)
        self.shoulder=to_mm(0.5)
        self.thickness = to_mm(kwargs.get('thickness'),safe=True)
        self.transition = cylinder(h=self.shoulder1, r=self.r1)+up(self.shoulder1+self.height)(cylinder(h=self.shoulder2, r=self.r4))+    up(self.shoulder1)(cylinder(h=self.height, r1=self.r2, r2=self.r3))

        if self.thickness:
            subtract =  cylinder(h=self.shoulder1, r=self.r1-self.thickness)+up(self.shoulder1+self.height)(cylinder(h=self.shoulder2, r=self.r4-self.thickness))+    up(self.shoulder1)(cylinder(h=self.height, r1=self.r2-self.thickness, r2=self.r3-self.thickness))
            self.transition -= subtract
 def __init__(self, length, thickness=None, major=None, minor=None, **kwargs):
     super(MorphedNoseCone, self).__init__(length, thickness, **kwargs)
     major = to_mm(major, self.outer_diameter / 2.)
     minor = to_mm(minor, self.outer_diameter / 4.)
     super(EllipseNoseCone, self).__init__(length, scale([major / minor, 1])(circle(r=minor)), thickness, **kwargs)
Example #22
0
    def __init__(self, retainer_diameter, height, depth, threads_per_inch, cap_diameter, hole_diameter, cap_thickness,**kwargs):
        r_r = to_mm(retainer_diameter/2.)
        height = to_mm(height)
        h_r = to_mm(hole_diameter/2.)
        c_r = to_mm(cap_diameter/2.)
        c_t = to_mm(cap_thickness)
        threads_per_inch = threads_per_inch
        o_d = kwargs.get('outer_diameter')
        i_d = kwargs.get('inner_diameter')

        if 'bodytube' in kwargs:
            o_d = kwargs['bodytube'].outer_diameter
            i_d = kwargs['bodytube'].inner_diameter

        print i_d
        i_r = to_mm(i_d/2.)
        o_r = to_mm(o_d/2.)

        print retainer_diameter
        flange_d = to_mm(kwargs.get('flange_diameter'), safe=True)
        flange_t = to_mm(kwargs.get('flange_thickness'), safe=True)
        
        spine_diameter = to_mm(kwargs.get('spine_diameter'), safe=True)

        round_radius = to_mm(kwargs.get('round_radius',0))

        if flange_d and flange_t:
            flange = cylinder(h=flange_t, r=flange_d/2.)
        else:
            flange = cylinder(h=height, r=o_r/2.)  # HACK because this will be removed

        self.retainer = difference() (self.threaded_male_column(height, to_mm(retainer_diameter), threads_per_inch) + flange,
                                      cylinder(h=height, r=o_r),
                                      up(height-depth), cylinder(h=depth, r=i_r))
        
        self.cap = difference()(cylinder(h=height,r=c_r),
                                self.threaded_female_column(height-c_t, to_mm(retainer_diameter), threads_per_inch),
                                cylinder(h=height, r=h_r))

        if spine_diameter:
            no_spines = kwargs.get('spines',0)
            spines = []
            for idx in xrange(0, no_spines):
                spines.append(rotate([0,0,360/no_spines*idx])(right(c_r)(cylinder(h=height-c_t-spine_diameter/2, r=spine_diameter/2)+
                                  up(height-c_t-spine_diameter/2)(sphere(r=spine_diameter/2.)))))
            self.cap+=union()(*spines)

        self.round = rotate_extrude()(right(c_r-round_radius)(square([round_radius,round_radius])*circle(round_radius)))
        self.cap -= up(height-round_radius)(rotate_extrude()(right(c_r-round_radius)(square([round_radius,round_radius]))))
        self.cap += up(height-round_radius)(self.round)
Example #23
0
from solid import multmatrix

from misc import utils
from .nosecone import DerivativeNoseCone
from misc.utils import to_mm


class ShearNoseCone(DerivativeNoseCone):
    def __init__(self, cone, x_shear, y_shear):
        super(DerivativeNoseCone, self).__init__(length=cone.length, thickness=cone.thickness,
                                                 outer_diameter=cone.outer_diameter, inner_diameter=cone.inner_diameter)
        shear_matrix = [[1, 0, x_shear / cone.length, 0],

                        [0, 1, y_shear / cone.length, 0],
                        [0, 0, 1, 0],
                        [0, 0, 0, 1]];
        self.cone = multmatrix(shear_matrix)(cone.cone)


if __name__ == '__main__':
    from standard_nosecones import EllipticalNoseCone, ConicalNoseCone, TangentOgiveNoseCone
    from bodytubes import semroc_bt5 as bt5

    utils.render_to_file(utils.array(2, to_mm(1), [
        ShearNoseCone(EllipticalNoseCone(length=.75, bodytube=bt5, thickness=1 / 16.), .25, .1),
        ShearNoseCone(ConicalNoseCone(length=.75, bodytube=bt5, thickness=1 / 16.), .25, .1),
        ShearNoseCone(ConicalNoseCone(length=.75, bodytube=bt5, thickness=1 / 16.), .25, 0),
        ShearNoseCone(TangentOgiveNoseCone(length=.75, bodytube=bt5, thickness=1 / 16.), .25, 0)]),
                         "examples/shear_nosecones.scad")
Example #24
0
""" Generate Examples"""
from nosecone.standard_nosecones import EllipticalNoseCone
from nosecone.nosecone_threaded_bases import *
from nosecone.nosecone_bases import *
from misc import utils
from bodytubes.semroc import bt5


if __name__ == '__main__':

    nc = EllipticalNoseCone(0.75, bodytube=bt5, thickness=1 / 16.0, base_height=0.25, blunt_radius=0.125,
                            mid_diameter=.3)

    array = utils.array_crosssection(4, utils.to_mm(1), [
        ThreadedBaseOutset(nc, shoulder=0.5),
        ThreadedBaseFlat(nc, shoulder=0.5),
        nc.crosssection(ThreadedBaseOutset(nc, shoulder=0.5).mate),
        BaseWithRing(HollowBaseCutout(nc, shoulder=0.5)),

        BaseWithElbow(HollowBaseCutout(nc, shoulder=0.5)),
        SolidBaseCutout(nc, shoulder=0.5),
        HollowBaseCutout(nc, shoulder=0.5),
        SolidBaseWithScrewHole(nc, shoulder=0.5, screw_diameter=1 / 16., screw_length=0.25),
        HollowBaseWithScrewHole(nc, shoulder=0.5, screw_diameter=1 / 16., screw_length=0.25),
        HollowBase(nc, shoulder=0.5),
        OpenBase(nc, shoulder=0.5), SolidBase(nc, shoulder=0.5), NoBase(nc),
    ])
    utils.render_to_file(array, "examples/nosecone_bases.scad")
 def fittest(self, height=.125):
     return cylinder(h=to_mm(height), r=self._i_r) - cylinder(
         h=to_mm(height), r=self._o_r)
Example #26
0
        self.cone = self.cone + up(offset)(cylinder(
            h=cone_length, r1=cone_radius, r2=0))
        """
        if self.thickness:
            thickness=to_mm(self.thickness)
            self.cone=self.cone+hull()(cone.cone)*up(offset+radius)(sphere(r=radius+thickness)-sphere(r=radius))
        """


''
if __name__ == '__main__':
    from standard_nosecones import EllipticalNoseCone, ConicalNoseCone, TangentOgiveNoseCone
    from bodytubes.semroc import bt5

    utils.render_to_file(
        utils.array(2, to_mm(1), [
            HollowTipNoseCone(
                EllipticalNoseCone(length=.75, bodytube=bt5,
                                   thickness=1 / 16.), .4, 1.),
            HollowTipNoseCone(
                EllipticalNoseCone(length=.75, bodytube=bt5,
                                   thickness=1 / 16.), .4, .75),
            HollowTipNoseCone(
                EllipticalNoseCone(length=.75, bodytube=bt5,
                                   thickness=1 / 16.), .4, .5),
            RamJetNoseCone(
                EllipticalNoseCone(length=.75, bodytube=bt5,
                                   thickness=1 / 16.), .4, 1., .25, .4),
            RamJetNoseCone(
                ConicalNoseCone(length=.75, bodytube=bt5, thickness=1 / 16.),
                .2, 1., .25, .4),
    from bodytubes.semroc import bt55
    from bodytubes.modelrockets_us import _3_00
    from nosecone_library.specific_noses import BNC5V
    from misc import utils

    nc = EllipticalNoseCone(2.75, bodytube=bt55, thickness=1 / 16.0)
    nc = BNC5V(scale_bodytube=_3_00, thickness=3 / 32.)
    sib = ScrewInBase(nc,
                      shoulder=0.5,
                      thread_height=0.75,
                      thread_diameter=1.2)
    sib = ScrewInBaseWithScrewHole(nc,
                                   shoulder=0.5,
                                   thread_height=0.75,
                                   thread_diameter=1.2,
                                   screw_diameter=1 / 16.,
                                   screw_length=0.25)
    sib = ThreadedBaseOutsetScrewInBase(nc,
                                        shoulder=1.5,
                                        thread_height=1.0,
                                        thread_diameter=2.8)

    array = utils.array(4, to_mm(5), [
        sib.crosssection(),
        nc.crosssection(sib.center_mate),
        nc.crosssection(sib.mate)
    ])
    #ThreadedBaseFlat(nc, shoulder=0.5).cone_section1,
    #        ThreadedBaseFlat(nc, shoulder=0.5).cone_section2])
    utils.render_to_file(array, "test.scad")