Skip to content

Commit

Permalink
Update make_grow_tower.py
Browse files Browse the repository at this point in the history
Cleaned it up a little.
  • Loading branch information
odellus authored Mar 21, 2018
1 parent d3e2e28 commit 9c01496
Showing 1 changed file with 30 additions and 5 deletions.
35 changes: 30 additions & 5 deletions make_grow_tower.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
vec = Base.Vector

class Config:
"""
Store all the constants in here that you need to access for later steps.
Compute a few, transfering logic in here it totally okay.
"""
def __init__(self):
self.outer_radius = 50
self.inner_radius = 44
Expand All @@ -28,13 +32,18 @@ def __init__(self):
self.angle = math.pi/3


config = Config()

def move_tube(part):
"""
move parts into position for the tube that holds net cup.
"""
part.rotate(vec(0, 0, 0), vec(0, 1, 0), 40)
part.translate(vec(10, 0, 4))

def make_raw_tower(config):
"""
Base design. Add / Subtract from this rough model to create finished
product.
"""
# Make main tower components inner and outer.
outer_radius = config.outer_radius
inner_radius = config.inner_radius
Expand All @@ -48,6 +57,7 @@ def make_raw_tower(config):
tube_height = config.tower_height
outer_tube = Part.makeCylinder(outer_tube_radius, tube_height)
inner_tube = Part.makeCylinder(inner_tube_radius, tube_height)

# Move them into position
move_tube(outer_tube)
move_tube(inner_tube)
Expand All @@ -72,26 +82,29 @@ def make_raw_tower(config):


def make_em_stack(tower_shell, config):
"""
Cut out rings on top and bottom to allow planter units to stack.
"""
tolerance = config.tolerance
cutout_thickness = config.cutout_thickness
outer_radius = config.outer_radius
inner_radius = config.inner_radius
cutout_height = config.cutout_height
tower_height = config.tower_height
bottom_ring_radius = config.bottom_ring_radius

# CUT INSIDE OUT ON TOP. WATER GOES DOWN.
# Move the shell up to the top before cutting out.
# move_up = tower_height - cutout_height
move_up = config.move_up

# Make it cut out wider by tolerance/2
# top_cutout_radius = inner_radius + cutout_thickness + tolerance/2
top_cutout_radius = config.top_cutout_radius
pan = Part.makeCylinder(top_cutout_radius, cutout_height)
pan.translate(vec(0, 0, move_up))
cut_top = tower_shell.cut(pan)

# CUT AROUND THE OUTER SURFACE ON BOTTOM. WATER GOES DOWN.
# Make it in deeper by tolerance/2
# bottom_cutaround_radius = outer_radius - cutout_thickness - tolerance/2
bottom_cutaround_radius = config.bottom_cutaround_radius
outer_ring = Part.makeCylinder(bottom_ring_radius, cutout_height)
inner_volume = Part.makeCylinder(bottom_cutaround_radius, cutout_height)
Expand All @@ -100,12 +113,17 @@ def make_em_stack(tower_shell, config):
return both_cut

def notch_it(tower_shell, config):
"""
Using small spheres, create notches and notch cutouts to lock towers
into a repeatable configuration. Keep them from sliding around z-axis.
"""
bottom_radius = config.bottom_cutaround_radius
cutout_height = config.cutout_height
bottom_notch_radius = 1 - config.tolerance / 2
bottom_notch = Part.makeSphere(bottom_notch_radius,
vec(bottom_radius, 0, cutout_height))

# The notches on the top need some elementary trig to calculate their position.
top_radius = config.top_cutout_radius
top_notch_radius = 1 + config.tolerance / 2
angle = config.angle
Expand All @@ -128,7 +146,14 @@ def notch_it(tower_shell, config):
return tower_shell_final

def make_it_all(config):
"""
make a raw tower, cut out rings, and notch.
"""
raw_tower = make_raw_tower(config)
cut_tower = make_em_stack(raw_tower, config)
finished_tower = notch_it(cut_tower, config)
return finished_tower

if __name__ == "__main__":
config = Config()
grow_tower = make_it_all(config)

0 comments on commit 9c01496

Please sign in to comment.