Ejemplo n.º 1
0
tensioner_assembly_left = tensioner_generator(False)
tensioner_assembly_right = tensioner_generator(True)

if __name__ == "__main__":

    def p(name, f=lambda x: x):
        print(name, f(globals()[name]))

    p("to_suspension_pivot")
    p("spring_anchor_point")
    p("arm_length")
    p("spring_arm_length")
    p("pivot_position")
    p("arm_angle_back")
    p("wheel_position_back")
    p("arm_angle_front")
    p("wheel_position_front")
    p("pivot_to_spring_anchor_angle")
    p("wheel_travel")
    p("wheel_x_travel")

    codecad.commandline_render(
        tensioner_generator(False, arm_angle_back).shape().rotated_z(
            180).translated_x(150) +
        tensioner_generator(False, arm_angle_front).shape().rotated_z(
            180).translated_z(70).translated_x(150) +
        tensioner_generator(False, arm_angle_back).shape() +
        tensioner_generator(False, arm_angle_front).shape().translated_z(70))
    #codecad.commandline_render(wheel_assembly)
Ejemplo n.º 2
0
# arrow = line(0, 0, l, 0, t) + line(l, 0, l - 10, 10, t) + line(l, 0, l - 10, -10, t)
x = line(-5, -10, 5, 10, t) + line(-5, 10, 5, -10, t)
y = line(-5, 10, 0, 0, t) + line(5, 10, 0, 0, t) + line(0, 0, 0, -10, t)
z = line(-5, 10, 5, 10, t) + line(5, 10, -5, -10, t) + line(-5, -10, 5, -10, t)
plus = line(-5, 0, 5, 0, t) + line(0, -5, 0, 5, t)
minus = line(-5, 0, 5, 0, t)
# arrows = arrow + arrow.rotated(90) + codecad.Circle(4 * t)

# def labeled_arrows(x_label, y_label):
#     return arrows + \
#            x_label.translated(l - 5, -25) + \
#            y_label.translated(-20, l - 10)


def cut(sym1, sym2):
    flat = sym1.translated(-7.5, 0) + sym2.translated(7.5, 0)
    extruded = flat.extruded(depth + 1).translated(0, 0, (a - depth + 1) / 2)
    return extruded


cube = codecad.shapes.box(a)

axes_cube = cube - (cut(plus, z) + cut(minus, y).rotated(
    (1, 0, 0), 90) + cut(plus, x).rotated((1, 0, 0), 90).rotated(
        (0, 0, 1), 90) + cut(plus, y).rotated((1, 0, 0), 90).rotated(
            (0, 0, 1), 180) + cut(minus, x).rotated((1, 0, 0), 90).rotated(
                (0, 0, 1), 270) + cut(minus, z).rotated((0, 1, 0), 180))

if __name__ == "__main__":
    codecad.commandline_render(axes_cube)
Ejemplo n.º 3
0
#!/usr/bin/env python3
""" CodeCad logo! """

import codecad
from codecad.shapes import *

width = 0.6
stroke = 0.2

# Build the C shape  1 unit high
c = (rectangle(width, 1 - width + stroke / 2) + circle(d=width).translated_y(
    (1 - width) / 2) + circle(d=width).translated_y(-(1 - width) / 2))
c = c.shell(stroke)
c -= rectangle(width, 1 - width).translated_x(width / 2)

# Scale it to 1 unit sized cube and prepare for adding
c = c.scaled(0.6).extruded(0.12).rotated_x(90).translated_y(-0.5)

# Put the logo together
logo = box() + c + c.rotated_z(90)
logo = logo.scaled(100).rotated_z(-45).rotated_x(15)

if __name__ == "__main__":
    codecad.commandline_render(logo)
Ejemplo n.º 4
0
Only has one face and one edge. """

import codecad
from codecad.shapes import *

minor_r = 15
major_r = 25
pin_d = 1.75
pin_h = 10
second_pin_angle = 170  # Not 180 degrees to have only one way to assemble

mp = regular_polygon2d(5, r=minor_r).revolved(r=major_r, twist=360 / 5)

pin_hole = cylinder(d=1.1 * pin_d, h=1.2 * pin_h).rotated_x(90).translated_x(major_r)
mp -= pin_hole
mp -= pin_hole.rotated_y(second_pin_angle)

half1 = (mp & half_space()).rotated_x(90).make_part("half1")
half2 = (mp - half_space()).rotated_x(-90).make_part("half2")

pin = cylinder(d=pin_d, h=pin_h, symmetrical=False).make_part("pin")
pin = pin.translated_z(-pin_h / 2).translated_x(major_r)

asm = codecad.assembly(
    "moebius_pentagon",
    [half1, half2.rotated_x(180), pin, pin.rotated_z(second_pin_angle)],
)

if __name__ == "__main__":
    codecad.commandline_render(asm)
Ejemplo n.º 5
0
#!/usr/bin/env python3

import os
import mesh

import codecad

chord = 200
span = 80
wall = 1
spacing = 20
rod_size = 2
path = os.path.join(os.path.dirname(__file__), "s1210-il.dat")

airfoil = codecad.shapes.airfoils.load_selig(path).scaled(chord)
base = airfoil.extruded(span, symmetrical=False)

inside = mesh.mesh(spacing, rod_size, -1) & base
skin = airfoil.shell(wall).extruded(span, symmetrical=False)
endcap = airfoil.extruded(wall, symmetrical=False)

o = (inside + skin + endcap).rotated_x(90)

if __name__ == "__main__":
    codecad.commandline_render(o)
Ejemplo n.º 6
0
plus = line(-5, 0, 5, 0, t) + line(0, -5, 0, 5, t)
minus = line(-5, 0, 5, 0, t)
# arrows = arrow + arrow.rotated(90) + codecad.Circle(4 * t)

# def labeled_arrows(x_label, y_label):
#     return arrows + \
#            x_label.translated(l - 5, -25) + \
#            y_label.translated(-20, l - 10)


def cut(sym1, sym2):
    flat = sym1.translated(-7.5, 0) + sym2.translated(7.5, 0)
    extruded = flat.extruded(depth + 1).translated(0, 0, (a - depth + 1) / 2)
    return extruded


cube = codecad.shapes.box(a)

axes_cube = cube - (
    cut(plus, z)
    + cut(minus, y).rotated((1, 0, 0), 90)
    + cut(plus, x).rotated((1, 0, 0), 90).rotated((0, 0, 1), 90)
    + cut(plus, y).rotated((1, 0, 0), 90).rotated((0, 0, 1), 180)
    + cut(minus, x).rotated((1, 0, 0), 90).rotated((0, 0, 1), 270)
    + cut(minus, z).rotated((0, 1, 0), 180)
)


if __name__ == "__main__":
    codecad.commandline_render(axes_cube)
Ejemplo n.º 7
0
                      5 * parameters.extrusion_width,
                      15,
                      parameters.max_overhang_angle) \
    .make_part("hull", ["3d_print"]) \
    .rotated_y(-90 + hull_rear_angle)

if __name__ == "__main__":

    def p(name, f=lambda x: x):
        print(name, f(globals()[name]))

    p("tensioner_position")
    p("bogie_positions")
    p("drive_sprocket_position")

    codecad.commandline_render((hull.shape() & half_space()))
    #codecad.commandline_render(codecad.assembly("hull_assembly", [hull]))

#thin_wall = 5 * parameters.extrusion_width
#
## Depth of the shoulder screw shaft in the side panel, including the spacing knob
#pivot_screw_diameter2_depth = parameters.shoulder_screw_length - parameters.shoulder_screw_screw_length \
#    - suspension.pivot_guide_length - suspension.pivot_flat_clearance
#
#side_thickness = pivot_screw_diameter2_depth - suspension.arm_clearance + thin_wall + \
#    max(parameters.large_screw_nut_height, parameters.shoulder_screw_nut_height) - suspension.pivot_flat_clearance
#side_pivot_height = suspension.arm_clearance - suspension.spring_anchor_point.z
#
#def side_generator(width, height, thickness,
#                   arm_clearance,
#                   suspension_pivot_z, suspension_pivot_diameter1, suspension_pivot_diameter2,
Ejemplo n.º 8
0
                      track.base_thickness, track.connector_length,
                      track.connector_thickness, track.connector_width,
                      track.width, track.guide_width, track.guide_height,
                      track.guide_side_angle, track.clearance)
spline = tools.spline(bearing.id)

inner_sprocket = inner_sprocket_generator(base,
                                          spline, 0.05,
                                          0.1, # Crown tolerance
                                          bearing.shoulder_size,
                                          bearing_shoulder_height + wheel_clearance,
                                          bearing_housing_top_diameter + 2 * wheel_clearance) \
    .make_part("inner_drive_sprocket", ["3d_print"])
outer_sprocket = outer_sprocket_generator(base,
                                          0.1, # Crown tolerance
                                          vitamins.m3x35_screw,
                                          center_screw_wall_thickness,

                                          3 * parameters.extrusion_width) \
    .make_part("outer_drive_sprocket", ["3d_print"])

drive_sprocket_assembly = codecad.assembly("drive_sprocket_assembly", [
    inner_sprocket.rotated_x(90).translated_y(track.width / 2),
    outer_sprocket.rotated_x(-90).translated_y(-track.width / 2)
])

if __name__ == "__main__":
    print("pitch radius", pitch_radius)

    codecad.commandline_render(drive_sprocket_assembly)
Ejemplo n.º 9
0
    for i in range(modelled_n):
        dist = (i - n / 2 + 0.5) * (segment_length + connector_length)

        conn = track_connector \
            .rotated_x(90) \
            .translated(dist + (segment_length + connector_length) / 2,
                        connector_width / 2,
                        0)

        parts.append(track_segment.translated_x(dist))
        parts.append(conn)
        parts.append(
            conn.translated_y((width - connector_width - clearance) / 2))
        parts.append(
            conn.translated_y(-(width - connector_width - clearance) / 2))

    hidden_n = n - modelled_n

    parts.extend(track_segment.hidden() for i in range(hidden_n))
    parts.extend(track_connector.hidden() for i in range(3 * hidden_n))
    parts.extend(vitamins.nail for i in range(4 * n))

    return codecad.assembly("track_assembly", parts)


track_assembly = track_row(120, 2)

if __name__ == "__main__":
    codecad.commandline_render(track_assembly)
Ejemplo n.º 10
0
                    - 2 * self.clearance
                    - self.sun_thickness
                    - self.motor_gear_thickness
                ),
                self.make_ring()
                .make_part("ring")
                .rotated_x(180)
                .translated_z(
                    self.outer_carrier_length
                    + self.inner_carrier_half_length
                    + self.bearing_wall_thickness
                    + self.clearance
                ),
            ]
            + [
                planet.rotated_z(i * 360 / self.planet_count)
                for i in range(self.planet_count)
            ],
        )

    def make_overview(self):
        """ Take the assembly and turn it into a piece good for showing off """
        return (self.make_assembly().shape() & s.half_space()).rotated_x(30)


if __name__ == "__main__":
    # Planetary.optimize()
    p = Planetary(11, 60, 13, 41, 18, 53)
    p.print_details()
    codecad.commandline_render(p.make_assembly())
Ejemplo n.º 11
0
#!/usr/bin/env python3
""" CodeCad logo! """

import codecad
from codecad.shapes import *

width = 0.6
stroke = 0.2

# Build the C shape  1 unit high
c = (
    rectangle(width, 1 - width + stroke / 2)
    + circle(d=width).translated_y((1 - width) / 2)
    + circle(d=width).translated_y(-(1 - width) / 2)
)
c = c.shell(stroke)
c -= rectangle(width, 1 - width).translated_x(width / 2)

# Scale it to 1 unit sized cube and prepare for adding
c = c.scaled(0.6).extruded(0.12).rotated_x(90).translated_y(-0.5)

# Put the logo together
logo = box() + c + c.rotated_z(90)
logo = logo.scaled(100).rotated_z(-45).rotated_x(15)

if __name__ == "__main__":
    codecad.commandline_render(logo)
Ejemplo n.º 12
0
#!/usr/bin/env python3

import codecad

rectangle = codecad.shapes.rectangle(5, 100).translated(50, 0)
circle = codecad.shapes.circle(r=20).translated(50, 50)

hole = codecad.shapes.rectangle(20).translated(50, 50)
notch = codecad.shapes.rectangle(15, 10).translated(55, 0)

shape = (rectangle + circle + notch) - hole

cutout = (codecad.shapes.box(200, float("inf"),
                             200).translated(100, 0, 100).rotated((0, 1, 0),
                                                                  -45))

o = shape.revolved() - cutout

o_display = o.rotated((0, 1, 0), 30).rotated((1, 0, 0), 45)

if __name__ == "__main__":
    codecad.commandline_render(o_display)
Ejemplo n.º 13
0
import codecad

import suspension
import drive_sprocket

layout = codecad.assembly("tank_layout_test_assembly", [
    suspension.suspension_assembly_left.hidden(),
    suspension.suspension_assembly_left.translated_x(
        suspension.suspension_spacing).hidden(),
    suspension.suspension_assembly_left.translated_x(
        2 * suspension.suspension_spacing),
    drive_sprocket.drive_sprocket_assembly.rotated_x(-90).translated_x(
        2 * suspension.suspension_spacing + 145)
])

if __name__ == "__main__":
    codecad.commandline_render(layout)
Ejemplo n.º 14
0
            [
                self.make_carrier_inner().make_part("inner_carrier").rotated_x(
                    180).translated_z(self.inner_carrier_half_length),
                self.make_carrier_outer().make_part("outer_carrier").rotated_x(
                    180).translated_z(self.outer_carrier_length +
                                      self.inner_carrier_half_length),
                self.make_sun().make_part("sun_gear").translated_z(
                    self.inner_carrier_half_length -
                    self.bearing_wall_thickness - 2 * self.clearance -
                    self.sun_thickness - self.motor_gear_thickness),
                self.make_ring().make_part("ring").rotated_x(180).translated_z(
                    self.outer_carrier_length +
                    self.inner_carrier_half_length +
                    self.bearing_wall_thickness + self.clearance),
            ] + [
                planet.rotated_z(i * 360 / self.planet_count)
                for i in range(self.planet_count)
            ],
        )

    def make_overview(self):
        """ Take the assembly and turn it into a piece good for showing off """
        return (self.make_assembly().shape() & s.half_space()).rotated_x(30)


if __name__ == "__main__":
    # Planetary.optimize()
    p = Planetary(11, 60, 13, 41, 18, 53)
    p.print_details()
    codecad.commandline_render(p.make_assembly())
Ejemplo n.º 15
0
#!/usr/bin/env python3

import codecad
import menger_sponge
import cube_thingie
import planetary
import airfoil

o = codecad.assembly(
    "benchmark_assembly",
    [
        planetary.Planetary(
            11, 60, 13, 41, 18,
            53).make_overview().make_part("sliced_gearbox").translated_x(-50),
        cube_thingie.cube_with_base(menger_sponge.sponge(6)).make_part(
            "menger_sponge_statue").translated_x(50),
        airfoil.o.make_part("meshed_airfoil").translated(-120, 0, 100),
    ],
)

if __name__ == "__main__":
    codecad.commandline_render(o)
Ejemplo n.º 16
0
shaft2 = shaft2_generator(drive_sprocket.spline, gear_shaft2_spline, 0.05,
                         vitamins.large_bearing,
                         (drive_sprocket.base.total_height + drive_sprocket.base.cone_height) / 2,
                         vitamins.m3x35_screw.diameter,
                         vitamins.m3x35_screw.length - drive_sprocket.center_screw_wall_thickness,
                         vitamins.m3x35_screw.lock_nut.s,
                         vitamins.m3x35_screw.lock_nut.height) \
    .make_part("transmission_shaft2", ["3d_print"])

shaft2_assembly = codecad.assembly("shaft2_assembly", [
    drive_sprocket.drive_sprocket_assembly,
    shaft2.rotated_x(90).translated_y(shaft2.part.data.length),
    vitamins.m3x35_screw, vitamins.m3x35_screw.lock_nut
])

if __name__ == "__main__":
    ratio = 1
    for t1, t2 in transmission_steps:
        assert math.gcd(t1, t2) == 1
        ratio *= t2 / t1

    speed = (motor_max_rpm / 60) * drive_sprocket.circumference / ratio
    print(
        "transmission ratios",
        ", ".join("{}:{}".format(*teeth) for teeth in transmission_steps),
        "({:.1f}:1) -> {:.1f}m/s, {:.1f}km/h".format(ratio, speed / 1000,
                                                     3.6 * speed / 1000))

    codecad.commandline_render(
        shaft2_assembly.rotated_z(90).shape() & half_space())
Ejemplo n.º 17
0
#!/usr/bin/env python3
import codecad

b1 = codecad.shapes.rectangle(50, 100)
b2 = codecad.shapes.rectangle(20, 80).rotated(45).translated(20, 0)

o1 = codecad.shapes.union([b1, b2])
o2 = codecad.shapes.union([b1, b2], 5)

o = o1.translated(-50, 0) + o2.translated(50, 0)

if __name__ == "__main__":
    codecad.commandline_render(o, 0.5, default_renderer="slice")
Ejemplo n.º 18
0
#!/usr/bin/env python3

import codecad

rectangle = codecad.shapes.rectangle(5, 100).translated(50, 0)
circle = codecad.shapes.circle(r=20).translated(50, 50)

hole = codecad.shapes.rectangle(20).translated(50, 50)
notch = codecad.shapes.rectangle(15, 10).translated(55, 0)

shape = (rectangle + circle + notch) - hole

cutout = (
    codecad.shapes.box(200, float("inf"), 200)
    .translated(100, 0, 100)
    .rotated((0, 1, 0), -45)
)

o = shape.revolved() - cutout

o_display = o.rotated((0, 1, 0), 30).rotated((1, 0, 0), 45)

if __name__ == "__main__":
    codecad.commandline_render(o_display)