Dateien hochladen nach „extensions“

Added ASCII and binary STL file mode
This commit is contained in:
Mario Voigt 2020-03-30 23:29:58 +02:00
parent 63ab306b23
commit e16b491bec
4 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>Papercraft Unfold ASCII</_name>
<id>fablabchemnitz.de.papercraft_unfold_ascii</id>
<dependency type="executable" location="extensions">fablabchemnitz_papercraft_unfold_ascii.py</dependency>
<input>
<extension>.stl</extension>
<mimetype>application/sla</mimetype>
<_filetypename>Unfoldable Stereolitography File ASCII (*.stl)</_filetypename>
<_filetypetooltip>Unfold STL Files</_filetypetooltip>
</input>
<script>
<command reldir="extensions" interpreter="python">fablabchemnitz_papercraft_unfold_ascii.py</command>
</script>
</inkscape-extension>

View File

@ -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()

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>Papercraft Unfold Binary</_name>
<id>fablabchemnitz.de.papercraft_unfold_binary</id>
<dependency type="executable" location="extensions">fablabchemnitz_papercraft_unfold_binary.py</dependency>
<input>
<extension>.stl</extension>
<mimetype>application/sla</mimetype>
<_filetypename>Unfoldable Stereolitography File Binary (*.stl)</_filetypename>
<_filetypetooltip>Unfold STL Files</_filetypetooltip>
</input>
<script>
<command reldir="extensions" interpreter="python">fablabchemnitz_papercraft_unfold_binary.py</command>
</script>
</inkscape-extension>

View File

@ -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()