Atomic exporter so fstl doesn't whine

This commit is contained in:
Roberto Alsina 2023-04-15 18:39:03 -03:00
parent cc1ff47e53
commit 07b9cc47ba
12 changed files with 34 additions and 24 deletions

View File

@ -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 $<

View File

@ -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",

View File

@ -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")

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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",
)

View File

@ -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")

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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)