mirror of
https://github.com/rsheldiii/KeyV2.git
synced 2025-09-14 08:09:55 +00:00
remove models directory and switch to generating them via script
This commit is contained in:
parent
c8b4011fac
commit
dc9b2a5aa6
8 changed files with 98 additions and 39 deletions
34
models.rb
Normal file
34
models.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
require './openscad.rb'
|
||||
require 'tempfile'
|
||||
|
||||
ROWS = [5,1,2,3,4].freeze
|
||||
SIZES = [1].freeze # , 1.25, 1.5, 1.75, 2, 2.25, 2.75, 6.25
|
||||
PROFILES = ['dcs', 'dsa', 'g20', 'oem', 'sa'].freeze
|
||||
|
||||
# can't get include statements to work dynamically so we'll just use a file
|
||||
def make_file(command)
|
||||
lines = OpenSCAD::expand('model_base.scad')
|
||||
lines << command
|
||||
f = Tempfile.new('models.scad')
|
||||
f.write lines.join
|
||||
f.close
|
||||
f.path
|
||||
end
|
||||
|
||||
# length is not used in the command here to get the automatic stabilizers from the script
|
||||
def make_command(row, length, profile)
|
||||
"key_profile(\"#{profile}\", #{row}) { union() { #{length == 6.25 ? '$dish_type = "sideways cylindrical"; $inverted_dish=true;' : ''} key(); } }"
|
||||
end
|
||||
|
||||
ROWS.each do |row|
|
||||
SIZES.each do |length|
|
||||
PROFILES.each do |profile|
|
||||
command = make_command(row, length, profile)
|
||||
filename = "#{profile}_row-#{row}_length-#{length.to_s.sub('.', '_')}.stl"
|
||||
puts "rendering #{filename}:"
|
||||
puts "\tcommand: #{command} \n\n"
|
||||
path = make_file(command)
|
||||
`openscad -o ./models/#{filename} -D "\\\$key_length = #{length};" #{path}`
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue