mirror of
https://github.com/DJSundog/NopSCADlib.git
synced 2024-11-27 09:10:02 -05:00
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 set_config import *
|
||||||
from deps import *
|
from deps import *
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
import re
|
||||||
|
|
||||||
source_dirs = { "stl" : "platters", "dxf" : "panels" }
|
source_dirs = { "stl" : "platters", "dxf" : "panels" }
|
||||||
target_dirs = { "stl" : "printed", "dxf" : "routed" }
|
target_dirs = { "stl" : "printed", "dxf" : "routed" }
|
||||||
@ -38,24 +39,32 @@ def plateup(target, part_type, usage = None):
|
|||||||
top_dir = set_config(target, usage)
|
top_dir = set_config(target, usage)
|
||||||
parts_dir = top_dir + part_type + 's'
|
parts_dir = top_dir + part_type + 's'
|
||||||
target_dir = parts_dir + '/' + target_dirs[part_type]
|
target_dir = parts_dir + '/' + target_dirs[part_type]
|
||||||
source_dir = top_dir + source_dirs[part_type]
|
source_dir1 = source_dirs[part_type]
|
||||||
deps_dir = source_dir + "/deps"
|
source_dir2 = top_dir + source_dirs[part_type]
|
||||||
if not os.path.isdir(source_dir):
|
#
|
||||||
return
|
# 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):
|
if not os.path.isdir(target_dir):
|
||||||
os.makedirs(target_dir)
|
os.makedirs(target_dir)
|
||||||
|
#
|
||||||
|
# Make the deps dir
|
||||||
|
#
|
||||||
|
deps_dir = dir + "/deps"
|
||||||
if not os.path.isdir(deps_dir):
|
if not os.path.isdir(deps_dir):
|
||||||
os.makedirs(deps_dir)
|
os.makedirs(deps_dir)
|
||||||
#
|
#
|
||||||
# Decide which files to make
|
# 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
|
# Run OpenSCAD on the source files to make the targets
|
||||||
#
|
#
|
||||||
used = []
|
|
||||||
for src in sources:
|
for src in sources:
|
||||||
src_file = source_dir + '/' + src
|
src_file = dir + '/' + src
|
||||||
part_file = target_dir + '/' + src[:-4] + part_type
|
part_file = target_dir + '/' + src[:-4] + part_type
|
||||||
dname = deps_name(deps_dir, src)
|
dname = deps_name(deps_dir, src)
|
||||||
changed = check_deps(part_file, dname)
|
changed = check_deps(part_file, dname)
|
||||||
@ -73,8 +82,9 @@ def plateup(target, part_type, usage = None):
|
|||||||
#
|
#
|
||||||
with open(log_name) as file:
|
with open(log_name) as file:
|
||||||
for line in file.readlines():
|
for line in file.readlines():
|
||||||
if line.startswith('ECHO: "~') and line.endswith('.' + part_type + '"\n'):
|
match = re.match(r'^ECHO: "~(.*?\.' + part_type + r').*"$', line)
|
||||||
used.append(line[8:-2])
|
if match:
|
||||||
|
used.append(match.group(1))
|
||||||
#
|
#
|
||||||
# Copy file that are not included
|
# 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
|
module use_stl(name) { //! Import an STL to make a build platter
|
||||||
stl(name);
|
stl(name);
|
||||||
|
path = is_undef($target) ? "../stls/" : str("../", $target, "/stls/");
|
||||||
import(str("../stls/", name, ".stl"));
|
import(str(path, name, ".stl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
module use_dxf(name) { //! Import a DXF to make a build panel
|
module use_dxf(name) { //! Import a DXF to make a build panel
|
||||||
dxf(name);
|
dxf(name);
|
||||||
|
path = is_undef($target) ? "../dxfs/" : str("../", $target, "/dxfs/");
|
||||||
import(str("../dxfs/", name, ".dxf"));
|
import(str(path, name, ".dxf"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user