From b1d5b6d5fe1d17847f7e4e5f2db8df63062e2fa2 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Mon, 30 Mar 2020 23:28:28 +0200 Subject: [PATCH] =?UTF-8?q?Dateien=20hochladen=20nach=20=E2=80=9E=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added version for ASCII and for finary STL files --- fablabchemnitz_papercraft_unfold_ascii.inx | 15 +++++++++ fablabchemnitz_papercraft_unfold_ascii.py | 34 +++++++++++++++++++++ fablabchemnitz_papercraft_unfold_binary.inx | 15 +++++++++ fablabchemnitz_papercraft_unfold_binary.py | 29 ++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 fablabchemnitz_papercraft_unfold_ascii.inx create mode 100644 fablabchemnitz_papercraft_unfold_ascii.py create mode 100644 fablabchemnitz_papercraft_unfold_binary.inx create mode 100644 fablabchemnitz_papercraft_unfold_binary.py diff --git a/fablabchemnitz_papercraft_unfold_ascii.inx b/fablabchemnitz_papercraft_unfold_ascii.inx new file mode 100644 index 0000000..f3cca11 --- /dev/null +++ b/fablabchemnitz_papercraft_unfold_ascii.inx @@ -0,0 +1,15 @@ + + + <_name>Papercraft Unfold ASCII + fablabchemnitz.de.papercraft_unfold_ascii + fablabchemnitz_papercraft_unfold_ascii.py + + .stl + application/sla + <_filetypename>Unfoldable Stereolitography File ASCII (*.stl) + <_filetypetooltip>Unfold STL Files + + + \ No newline at end of file diff --git a/fablabchemnitz_papercraft_unfold_ascii.py b/fablabchemnitz_papercraft_unfold_ascii.py new file mode 100644 index 0000000..b5b6401 --- /dev/null +++ b/fablabchemnitz_papercraft_unfold_ascii.py @@ -0,0 +1,34 @@ +import sys +from subprocess import Popen, PIPE +import subprocess +import inkex +import os +class Unfold: + def __init__(self): + stl_filename = inkex.sys.argv[1] + #inkex.debug("stl_filename: "+stl_filename) + if os.name=="nt": + outname = "papercraft_unfold_output.svg" + #remove old file if existent + if os.path.exists(outname): + os.remove(outname) + if os.path.exists("unfold.exe.stackdump"): + os.remove("unfold.exe.stackdump") + #convert the STL to have a binary one and wait until conversion finished before running papercraft + cmd = os.getcwd() + "\\papercraft\\STLConverter.exe" + " " + stl_filename + p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) + #inkex.debug(cmd) + #inkex.debug("os.getcwd(): "+os.getcwd()) + #inkex.debug(os.path.splitext(stl_filename)[0]) + p.wait() + cmd2 = os.getcwd() + "\\papercraft\\unfold.exe" + " < " + os.path.splitext(stl_filename)[0] + "-binary.stl > " + outname + #inkex.debug("cmd2: "+cmd2) + p2 = Popen(cmd2, shell=True, stdout=PIPE, stderr=PIPE) + #inkex.debug(p2.communicate()) + p2.wait() + if p2.returncode == 0: + #inkex.debug("OK") + doc = inkex.etree.parse(os.getcwd() + "\\" + outname) + doc.write(inkex.sys.stdout) +if __name__ == '__main__': + gc = Unfold() \ No newline at end of file diff --git a/fablabchemnitz_papercraft_unfold_binary.inx b/fablabchemnitz_papercraft_unfold_binary.inx new file mode 100644 index 0000000..7380afb --- /dev/null +++ b/fablabchemnitz_papercraft_unfold_binary.inx @@ -0,0 +1,15 @@ + + + <_name>Papercraft Unfold Binary + fablabchemnitz.de.papercraft_unfold_binary + fablabchemnitz_papercraft_unfold_binary.py + + .stl + application/sla + <_filetypename>Unfoldable Stereolitography File Binary (*.stl) + <_filetypetooltip>Unfold STL Files + + + \ No newline at end of file diff --git a/fablabchemnitz_papercraft_unfold_binary.py b/fablabchemnitz_papercraft_unfold_binary.py new file mode 100644 index 0000000..a3a1fc2 --- /dev/null +++ b/fablabchemnitz_papercraft_unfold_binary.py @@ -0,0 +1,29 @@ +import sys +from subprocess import Popen, PIPE +import subprocess +import inkex +import os +class Unfold: + def __init__(self): + stl_filename = inkex.sys.argv[1] + #inkex.debug("stl_filename: "+stl_filename) + if os.name=="nt": + outname = "papercraft_unfold_output.svg" + #remove old file if existent + if os.path.exists(outname): + os.remove(outname) + if os.path.exists("unfold.exe.stackdump"): + os.remove("unfold.exe.stackdump") + #inkex.debug("os.getcwd(): "+os.getcwd()) + #inkex.debug(os.path.splitext(stl_filename)[0]) + cmd = os.getcwd() + "\\papercraft\\unfold.exe" + " < " + stl_filename + " > " + outname + #inkex.debug("cmd: "+cmd) + p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) + #inkex.debug(p.communicate()) + p.wait() + if p.returncode == 0: + #inkex.debug("OK") + doc = inkex.etree.parse(os.getcwd() + "\\" + outname) + doc.write(inkex.sys.stdout) +if __name__ == '__main__': + gc = Unfold() \ No newline at end of file