tweak the fit of the parts

This commit is contained in:
Nick Estes
2026-08-04 12:27:31 -07:00
parent 45a77885f9
commit 69d9b956e6
41 changed files with 5378 additions and 324 deletions
+40 -4
View File
@@ -68,6 +68,30 @@ class PackageBuilderTest < Minitest::Test
end
end
def test_builds_aligned_multicolor_lid_package_when_artwork_is_enabled
Dir.mktmpdir do |directory|
root = Pathname(directory)
tools = create_fake_tools(root)
model = root.join("model.scad")
renderer = root.join("renderer.py")
File.write(model, "cube([1,1,1]);\n")
File.write(renderer, "# test renderer\n")
config = FeatherCaseWizard::Config.create(name: "IMU", slug: "imu")
config.parameters["lid_label"] = "IMU"
config.parameters["lid_logo_enabled"] = true
destination = build(config, root.join("cases"), tools, model, renderer)
%w[lid lid_base lid_accent].each do |part|
assert destination.join("exports/3mf/#{part}.3mf").file?
end
assert destination.join("exports/3mf/lid_multicolor.3mf").file?
assert destination.join("source/assets/NME-fixed.svg").file?
assert destination.join("tools/package_multimaterial_3mf.py").file?
assert destination.join("previews/lid_multicolor_top.png").file?
end
end
private
def build(config, root, tools, model, renderer)
@@ -93,14 +117,26 @@ class PackageBuilderTest < Minitest::Test
#!/usr/bin/env ruby
require "fileutils"
args = ARGV[(ARGV.index("--") + 1)..]
_mesh, output, basename, selected = args
views = selected ? selected.split(",") : %w[iso front back left right top]
multicolor = ARGV[ARGV.index("--python") + 1].include?("render_multicolor")
if multicolor
_base, _accent, output, basename = args
views = %w[iso top]
else
_mesh, output, basename, selected = args
views = selected ? selected.split(",") : %w[iso front back left right top]
end
FileUtils.mkdir_p(output)
views.each { |view| File.binwrite(File.join(output, "\#{basename}_\#{view}.png"), "png") }
RUBY
FileUtils.chmod(0o755, [openscad, blender])
python = bin.join("python3")
File.write(python, <<~RUBY)
#!/usr/bin/env ruby
File.binwrite(ARGV[3], "multipart")
RUBY
FileUtils.chmod(0o755, [openscad, blender, python])
FeatherCaseWizard::Toolchain.new(
env: {"PATH" => bin.to_s, "OPENSCAD" => openscad.to_s, "BLENDER" => blender.to_s}
env: {"PATH" => bin.to_s, "OPENSCAD" => openscad.to_s,
"BLENDER" => blender.to_s, "PYTHON" => python.to_s}
)
end
end