Mods to allow panels and platters to be target specific or not.
This commit is contained in:
parent
a547c98995
commit
1f1a360b7c
|
@ -27,6 +27,7 @@ import c14n_stl
|
|||
from set_config import *
|
||||
from deps import *
|
||||
from shutil import copyfile
|
||||
import re
|
||||
|
||||
source_dirs = { "stl" : "platters", "dxf" : "panels" }
|
||||
target_dirs = { "stl" : "printed", "dxf" : "routed" }
|
||||
|
@ -38,24 +39,32 @@ def plateup(target, part_type, usage = None):
|
|||
top_dir = set_config(target, usage)
|
||||
parts_dir = top_dir + part_type + 's'
|
||||
target_dir = parts_dir + '/' + target_dirs[part_type]
|
||||
source_dir = top_dir + source_dirs[part_type]
|
||||
deps_dir = source_dir + "/deps"
|
||||
if not os.path.isdir(source_dir):
|
||||
return
|
||||
source_dir1 = source_dirs[part_type]
|
||||
source_dir2 = top_dir + source_dirs[part_type]
|
||||
#
|
||||
# Loop through source directories
|
||||
#
|
||||
used = []
|
||||
for dir in [source_dir1, source_dir2]:
|
||||
if not os.path.isdir(dir):
|
||||
continue
|
||||
if not os.path.isdir(target_dir):
|
||||
os.makedirs(target_dir)
|
||||
#
|
||||
# Make the deps dir
|
||||
#
|
||||
deps_dir = dir + "/deps"
|
||||
if not os.path.isdir(deps_dir):
|
||||
os.makedirs(deps_dir)
|
||||
#
|
||||
# Decide which files to make
|
||||
#
|
||||
sources = [file for file in os.listdir(source_dir) if file.endswith('.scad')]
|
||||
sources = [file for file in os.listdir(dir) if file.endswith('.scad')]
|
||||
#
|
||||
# Run OpenSCAD on the source files to make the targets
|
||||
#
|
||||
used = []
|
||||
for src in sources:
|
||||
src_file = source_dir + '/' + src
|
||||
src_file = dir + '/' + src
|
||||
part_file = target_dir + '/' + src[:-4] + part_type
|
||||
dname = deps_name(deps_dir, src)
|
||||
changed = check_deps(part_file, dname)
|
||||
|
@ -73,8 +82,9 @@ def plateup(target, part_type, usage = None):
|
|||
#
|
||||
with open(log_name) as file:
|
||||
for line in file.readlines():
|
||||
if line.startswith('ECHO: "~') and line.endswith('.' + part_type + '"\n'):
|
||||
used.append(line[8:-2])
|
||||
match = re.match(r'^ECHO: "~(.*?\.' + part_type + r').*"$', line)
|
||||
if match:
|
||||
used.append(match.group(1))
|
||||
#
|
||||
# Copy file that are not included
|
||||
#
|
||||
|
|
|
@ -28,12 +28,12 @@ use <global.scad>
|
|||
|
||||
module use_stl(name) { //! Import an STL to make a build platter
|
||||
stl(name);
|
||||
|
||||
import(str("../stls/", name, ".stl"));
|
||||
path = is_undef($target) ? "../stls/" : str("../", $target, "/stls/");
|
||||
import(str(path, name, ".stl"));
|
||||
}
|
||||
|
||||
module use_dxf(name) { //! Import a DXF to make a build panel
|
||||
dxf(name);
|
||||
|
||||
import(str("../dxfs/", name, ".dxf"));
|
||||
path = is_undef($target) ? "../dxfs/" : str("../", $target, "/dxfs/");
|
||||
import(str(path, name, ".dxf"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue