예제 #1
0
#
# First run: Just export the given filetype
# For any --render arguments to --render=cgal
#
tmpargs =  ['--render=cgal' if arg.startswith('--render') else arg for arg in remaining_args]

export_cmd = [args.openscad, inputfile, '-o', exportfile] + tmpargs
print >> sys.stderr, 'Running OpenSCAD #1:'
print >> sys.stderr, ' '.join(export_cmd)
result = subprocess.call(export_cmd)
if result != 0:
	failquit('OpenSCAD #1 failed with return code ' + str(result))

if args.format == 'stl' and args.requiremanifold:
        if not validateSTL(exportfile):
                failquit("Error: Non-manifold STL file exported from OpenSCAD")


#
# Second run: Import the exported file and render as png
#
newscadfile = exportfile
# If we didn't export a .csg file, we need to import it
if args.format != 'csg':
        newscadfile += '.scad'
        createImport(exportfile, newscadfile)

create_png_cmd = [args.openscad, newscadfile, '-o', pngfile] + remaining_args
print >> sys.stderr, 'Running OpenSCAD #2:'
print >> sys.stderr, ' '.join(create_png_cmd)
예제 #2
0
    '--render=cgal' if arg.startswith('--render') else arg
    for arg in remaining_args
]

if export_format is not None:
    tmpargs.extend(['--export-format', export_format])

export_cmd = [args.openscad, inputfile, '-o', exportfile] + tmpargs
print('Running OpenSCAD #1:', file=sys.stderr)
print(' '.join(export_cmd), file=sys.stderr)
result = subprocess.call(export_cmd)
if result != 0:
    failquit('OpenSCAD #1 failed with return code ' + str(result))

if args.format == 'stl' and args.requiremanifold:
    if not validateSTL(exportfile):
        failquit("Error: Non-manifold STL file exported from OpenSCAD")

#
# Second run: Import the exported file and render as png
#
newscadfile = exportfile
# If we didn't export a .csg file, we need to import it
if args.format != 'csg':
    newscadfile += '.scad'
    createImport(exportfile, newscadfile)

create_png_cmd = [args.openscad, newscadfile, '-o', pngfile] + remaining_args
print('Running OpenSCAD #2:', file=sys.stderr)
print(' '.join(create_png_cmd), file=sys.stderr)
fontdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "data/ttf"))
예제 #3
0
#!/usr/bin/env python

import re, sys, subprocess, os
from validatestl import validateSTL

stlfile = sys.argv[3] + '.stl'

subprocess.check_call([sys.argv[2], sys.argv[1], '-o', stlfile])

ret = validateSTL(stlfile)
os.unlink(stlfile)

if not ret:
    sys.exit(1)