diff --git a/notebook_nueva/Makefile b/notebook_nueva/Makefile index 7bb2cc9..7a9ede9 100644 --- a/notebook_nueva/Makefile +++ b/notebook_nueva/Makefile @@ -2,5 +2,5 @@ STL_FILES = base.stl hinged_lid.stl simple_lid.stl tandy_lid.stl all: $(STL_FILES) -%.stl: %.py dimensions.py +%.stl: %.py dimensions.py utils.py python $< \ No newline at end of file diff --git a/notebook_nueva/base.py b/notebook_nueva/base.py index 9040ed4..8beeff8 100644 --- a/notebook_nueva/base.py +++ b/notebook_nueva/base.py @@ -1,5 +1,4 @@ import cadquery as cq -from cadquery import exporters from cq_warehouse.drafting import Draft import audio_plug @@ -11,6 +10,8 @@ import usb_hub import zero_holder as cpu_holder import dimensions as dim +from utils import export + # Base for the notebook. Basically a kbd base that extends back # as much as possible @@ -147,7 +148,7 @@ if __name__ == "__main__": .cutBlind(100) ) - exporters.export(right_side, "base_right.stl") + export(right_side, "base_right.stl") right_cutout = cq.Sketch().polygon( [ @@ -168,7 +169,7 @@ if __name__ == "__main__": .placeSketch(right_cutout) .cutBlind(100) ) - exporters.export(left_side, "base_left.stl") + export(left_side, "base_left.stl") # draft = Draft(decimal_precision=1) # dimensions = [] @@ -191,13 +192,13 @@ if __name__ == "__main__": # ) # ) - exporters.export(model, "base.stl") + export(model, "base.stl") # for d in dimensions[1:]: # dimensions[0].add(d.toCompound()) # dimensions[0].add(model) - exporters.export( + export( # model[0].toCompound(), model, "base.svg", diff --git a/notebook_nueva/hinged_lid.py b/notebook_nueva/hinged_lid.py index f7d2ba4..382d7a2 100644 --- a/notebook_nueva/hinged_lid.py +++ b/notebook_nueva/hinged_lid.py @@ -1,8 +1,8 @@ import cadquery as cq -from cadquery import exporters import dimensions as dim import keyboard +from utils import export mounting_pillar_positions = [(x, -y) for x, y in dim.mounting_pillar_positions] mounting_pillars = ( @@ -383,11 +383,11 @@ def front_bezel(): if __name__ == "__main__": model = model() - exporters.export(model, "hinged_lid.stl") + export(model, "hinged_lid.stl") - exporters.export(front_bezel(), "hinged_lid_bezel.stl") + export(front_bezel(), "hinged_lid_bezel.stl") - exporters.export( + export( model, "hinged_lid.svg", opt={ @@ -404,7 +404,7 @@ if __name__ == "__main__": .split(keepTop=True) ) - exporters.export(right_side, "hinged_lid_right.stl") + export(right_side, "hinged_lid_right.stl") left_side = ( model.faces(">X") @@ -412,4 +412,4 @@ if __name__ == "__main__": .split(keepBottom=True) ) - exporters.export(left_side, "hinged_lid_left.stl") + export(left_side, "hinged_lid_left.stl") diff --git a/notebook_nueva/hinged_lid.stl b/notebook_nueva/hinged_lid.stl index b6288b1..6311f01 100644 Binary files a/notebook_nueva/hinged_lid.stl and b/notebook_nueva/hinged_lid.stl differ diff --git a/notebook_nueva/hinged_lid_left.stl b/notebook_nueva/hinged_lid_left.stl index 894dbb2..5348182 100644 Binary files a/notebook_nueva/hinged_lid_left.stl and b/notebook_nueva/hinged_lid_left.stl differ diff --git a/notebook_nueva/hinged_lid_right.stl b/notebook_nueva/hinged_lid_right.stl index 22dc7e3..f4655d6 100644 Binary files a/notebook_nueva/hinged_lid_right.stl and b/notebook_nueva/hinged_lid_right.stl differ diff --git a/notebook_nueva/simple_lid.py b/notebook_nueva/simple_lid.py index 55ab900..980d20c 100644 --- a/notebook_nueva/simple_lid.py +++ b/notebook_nueva/simple_lid.py @@ -1,8 +1,7 @@ import cadquery as cq -from cadquery import exporters import dimensions as dim -from utils import extrude_shape2, hex_vents, punch_hole +from utils import extrude_shape2, hex_vents, punch_hole, export def model(): @@ -85,12 +84,12 @@ def decorative_cover(): if __name__ == "__main__": model = model() - exporters.export(model, "simple_lid.stl") + export(model, "simple_lid.stl") cover = decorative_cover() - exporters.export(cover, "simple_lid_cover.stl") + export(cover, "simple_lid_cover.stl") - exporters.export( + export( model, "lid.svg", opt={ @@ -98,11 +97,11 @@ if __name__ == "__main__": }, ) - exporters.export( + export( model.faces(">X").workplane(offset=-dim.width / 2).split(keepTop=True), "simple_lid_right.stl", ) - exporters.export( + export( model.faces(">X").workplane(offset=-dim.width / 2).split(keepBottom=True), "simple_lid_left.stl", ) diff --git a/notebook_nueva/tandy_lid.py b/notebook_nueva/tandy_lid.py index 02cc717..74df11e 100644 --- a/notebook_nueva/tandy_lid.py +++ b/notebook_nueva/tandy_lid.py @@ -1,7 +1,7 @@ import cadquery as cq -from cadquery import exporters import dimensions as dim +from utils import export viewport_cutout = ( cq.Sketch().trapezoid(dim.vis_w, dim.vis_h, 90, mode="a").vertices().fillet(2) @@ -111,7 +111,7 @@ def model(): if __name__ == "__main__": model = model() - exporters.export(model, "tandy_lid.stl") + export(model, "tandy_lid.stl") offset_width = -dim.width / 2 @@ -121,7 +121,7 @@ if __name__ == "__main__": .split(keepTop=True) ) - exporters.export(right_side, "tandy_lid_right.stl") + export(right_side, "tandy_lid_right.stl") left_side = ( model.faces(">X") @@ -129,4 +129,4 @@ if __name__ == "__main__": .split(keepBottom=True) ) - exporters.export(left_side, "tandy_lid_left.stl") + export(left_side, "tandy_lid_left.stl") diff --git a/notebook_nueva/tandy_lid.stl b/notebook_nueva/tandy_lid.stl index e2c4e1e..21602db 100644 Binary files a/notebook_nueva/tandy_lid.stl and b/notebook_nueva/tandy_lid.stl differ diff --git a/notebook_nueva/tandy_lid_left.stl b/notebook_nueva/tandy_lid_left.stl index 6fbf227..80cdd6d 100644 Binary files a/notebook_nueva/tandy_lid_left.stl and b/notebook_nueva/tandy_lid_left.stl differ diff --git a/notebook_nueva/tandy_lid_right.stl b/notebook_nueva/tandy_lid_right.stl index 02ffa2e..e894ab9 100644 Binary files a/notebook_nueva/tandy_lid_right.stl and b/notebook_nueva/tandy_lid_right.stl differ diff --git a/notebook_nueva/utils.py b/notebook_nueva/utils.py index ecdeda6..8837f43 100644 --- a/notebook_nueva/utils.py +++ b/notebook_nueva/utils.py @@ -1,6 +1,10 @@ -import cadquery as cq +import shutil +import tempfile from math import floor +import cadquery as cq +from cadquery import exporters + def extrude_shape(*, model, face, w, h, x_offset, y_offset, element, height): return ( @@ -71,3 +75,9 @@ def hex_vents(*, size, width, height, density=0.85): ] return vents + + +def export(model, fname, **kwarg): + tmpfile = tempfile.mktemp(suffix="." + fname.split(".")[-1]) + exporters.export(model, tmpfile, **kwarg) + shutil.move(tmpfile, fname)