I've created a script, which loads STP-files and converts them to SVGs. Unfortunately, this script:
- eats up more and more memory with every STP-file I load/convert, up to several GB
- on exit, shows an error-message for each loaded STP-file:
Exception while processing file: FILE1.stp [Cannot load Gui module in console application.]
Exception while processing file: FILE2.stp [Cannot load Gui module in console application.]
...
So: Can you tell me what I'm doing wrong? Or is this a bug in FreeCAD?
Here's the script:
Code: Select all
#!/usr/bin/env FreeCADCmd
#
# Convert 3D-files to SVG (in the default view) via FreeCAD
#
# :Author: Roland Freikamp
# :Version: 2020-01-17
import os
import sys
import FreeCAD
import Part
import importSVG
print("== Convert 3D-files to SVG")
for filename in sys.argv[2:]:
svgfile = os.path.splitext(filename)[0].replace(" ","_") + ".svg"
print("-- %s -> %s" % (filename, svgfile))
if not os.path.exists(filename):
print("ERROR: '%s' does not exist." % filename)
continue
if os.path.exists(svgfile):
print("ERROR: SVG-file '%s' already exists." % svgfile)
continue
doc = FreeCAD.newDocument("doc")
p = Part.read(filename)
f = doc.addObject("Part::Feature", "obj")
f.Shape = p
doc.recompute()
importSVG.export([doc.getObject("obj")], svgfile)
doc.removeObject("obj")
FreeCAD.closeDocument("doc")