Skip to content

Instantly share code, notes, and snippets.

@medicationforall
Last active July 23, 2023 09:30
Show Gist options
  • Save medicationforall/b4d2dd2b70ed0b7f7e23e62a5f5a7256 to your computer and use it in GitHub Desktop.
Save medicationforall/b4d2dd2b70ed0b7f7e23e62a5f5a7256 to your computer and use it in GitHub Desktop.
import random
import cadquery as cq
from cqindustry import Walkway
from cqterrain import tile as terrain_tile, greeble
from cadqueryhelper import irregular_grid, series
def __windmill(length, width, height):
if length / width == 1:
return terrain_tile.windmill(
tile_size = length,
height = height
)
else:
return terrain_tile.rivet(length, width, height)
def __trench(length, width, height):
return terrain_tile.chamfer_frame(
length,
width,
height,
chamfer_length = 0.1
)
tile_styles = [
terrain_tile.plain,
__trench,
terrain_tile.rivet,
terrain_tile.slot,
__windmill
]
tile_styles_count = len(tile_styles)
def custom_tile2(length, width, height):
tile_style = random.randrange(0,tile_styles_count)
if tile_style in range(tile_styles_count):
tile = tile_styles[tile_style](length, width, height)
else:
raise Exception(f"unknown tyle style {tile_style}")
return tile
def custom_item(length, width, height):
return (
cq.Workplane("XY")
.box(length, width, height)
.chamfer(0.5)
)
bricks = irregular_grid(
length = 175,
width = 30,
height = 4,
col_size = 5,
row_size = 5,
max_columns = 4,
max_rows = 4,
max_height=5,
align_z = True,
include_outline = True,
union_grid = True,
passes_count = 200,
seed = "purple",
make_item = custom_item
).rotate((1,0,0),(0,0,0),-90).translate((0,29.5,18))
bp = Walkway()
bp.length = 175
bp.width = 62.5
bp.height = 6
bp.render_tabs=False
bp.render_rails = 'left'
bp.rail_width = 6
bp.rail_height = 30
bp.rail_chamfer = 25
bp.rail_slot_type = 'archround'
bp.rail_slot_length = 16
bp.rail_slot_pointed_inner_height = 9
bp.rail_slot_top_padding = 10
bp.rail_slot_length_offset = 10
bp.rail_slots_end_margin = 15
bp.render_slots = 'irregular'#False
bp.tile_max_height = 4
bp.tile_seed = 'spiteclawswarm3'
bp.make_tile_method = custom_tile2
bp.tile_max_columns = 4
bp.tile_max_rows = 4
bp.make()
bp.rails = bp.rails.intersect(bricks)
display = bp.build()
base_height = 3.5
base_radius = 12.6
center_base_radius = 16.1
center_base = (
cq.Workplane("XY")
.cylinder(base_height, center_base_radius)
)
base = (
cq.Workplane("XY")
.cylinder(base_height, base_radius)
)
pip_height = 2.3
pip_radius = 1.56
magnet = (
cq.Workplane("XY")
.cylinder(pip_height, pip_radius)
)
base_mag_height = base_height+pip_height
base_mag = (
cq.Workplane("XY")
.union(base)
.union(magnet.translate((0,0,-1*(base_mag_height/2))))
)
center_base_mag = (
cq.Workplane("XY")
.union(center_base)
.union(magnet.translate((0,0,-1*(base_mag_height/2))))
)
x_translate = 33
y_translate = 30
row_2_offset = 12
bases = (
cq.Workplane("XY")
#row 1
.union(center_base_mag)
.union(base_mag.translate((-x_translate,0,0)))
.union(base_mag.translate((x_translate,0,0)))
.union(base_mag.translate((-x_translate*2,0,0)))
.union(base_mag.translate((x_translate*2,0,0)))
).translate((0,0,0))
cyl = cq.Workplane("XY").cylinder(20,1)
bar_series = series(
shape = cyl,
length_offset=-8,
width_offset=None,
height_offset=None, size=20)
bar_series = bar_series.translate((0,28,10+3))
scene = (
cq.Workplane("XY")
.union(display)
.cut(bases.translate((0,0,((bp.height/2)-base_height/2)+1.5)))
.union(bar_series)
)
#show_object(scene)
cq.exporters.export(scene, "stl/minidisplay_spiteclaw.stl")
@medicationforall
Copy link
Author

08_minidisplay_spiteclaw

11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment