summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorMichael Schwarz <michi.schwarz@gmail.com>2015-03-14 12:14:47 +0100
committerMichael Schwarz <michi.schwarz@gmail.com>2015-03-15 12:12:01 +0100
commite232c40ef7f25f8e73f7d6c07a18dc199a8c029a (patch)
tree690c6d815531422d4f8e2d8fbf50a118f3ff44f7 /support
parentb81d25712705661f7bab95252ff9cae97a9f4b37 (diff)
downloadpogojig-e232c40ef7f25f8e73f7d6c07a18dc199a8c029a.tar.gz
pogojig-e232c40ef7f25f8e73f7d6c07a18dc199a8c029a.tar.bz2
pogojig-e232c40ef7f25f8e73f7d6c07a18dc199a8c029a.zip
Compile OpenSCAD files to DXF.
This adds support to selectively compile some OpenSCAD files to DXF instead of STL.
Diffstat (limited to 'support')
-rw-r--r--support/openscad/__main__.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/support/openscad/__main__.py b/support/openscad/__main__.py
index 3c103e5..bc1135d 100644
--- a/support/openscad/__main__.py
+++ b/support/openscad/__main__.py
@@ -21,14 +21,16 @@ def main(in_path, out_path, deps_path):
temp_mk_path = os.path.join(temp_dir, 'mk')
temp_files_path = os.path.join(temp_dir, 'files')
- # OpenSCAD requires the output file name to end in .stl
- temp_stl_path = os.path.join(temp_dir, 'out.stl')
+ _, out_ext = os.path.splitext(out_path)
- _openscad(in_path, temp_stl_path, temp_deps_path)
+ # OpenSCAD requires the output file name to end in .stl or .dxf.
+ temp_out_path = os.path.join(temp_dir, 'out' + out_ext)
+
+ _openscad(in_path, temp_out_path, temp_deps_path)
mk_content = '%:; echo "$@" >> {}'.format(util.bash_escape_string(temp_files_path))
- # Use make to parse the dependency makefile written by OpenSCAD
+ # Use make to parse the dependency makefile written by OpenSCAD.
util.write_file(temp_mk_path, mk_content.encode())
util.command(['make', '-s', '-B', '-f', temp_mk_path, '-f', temp_deps_path])
@@ -36,11 +38,11 @@ def main(in_path, out_path, deps_path):
deps = set(map(relpath, util.read_file(temp_files_path).decode().splitlines()))
# Relative paths to all files that should not appear in the dependency makefile.
- ignored_files = set(map(relpath, [in_path, temp_deps_path, temp_mk_path, temp_stl_path]))
+ ignored_files = set(map(relpath, [in_path, temp_deps_path, temp_mk_path, temp_out_path]))
# Write output files.
_write_dependencies(deps_path, relpath(out_path), deps - ignored_files)
- os.rename(temp_stl_path, out_path)
+ os.rename(temp_out_path, out_path)
try: