3 This page is in the table of contents.
6 Cura is a AGPL tool chain to generate a GCode path for 3D printing. Older versions of Cura where based on Skeinforge.
7 Versions up from 13.05 are based on a C++ engine called CuraEngine.
9 from __future__ import absolute_import
10 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
12 from optparse import OptionParser
14 from Cura.util import profile
17 parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
18 parser.add_option("-i", "--ini", action="store", type="string", dest="profileini",
19 help="Load settings from a profile ini file")
20 parser.add_option("-r", "--print", action="store", type="string", dest="printfile",
21 help="Open the printing interface, instead of the normal cura interface.")
22 parser.add_option("-p", "--profile", action="store", type="string", dest="profile",
23 help="Internal option, do not use!")
24 parser.add_option("-s", "--slice", action="store_true", dest="slice",
25 help="Slice the given files instead of opening them in Cura")
26 parser.add_option("-o", "--output", action="store", type="string", dest="output",
27 help="path to write sliced file to")
29 (options, args) = parser.parse_args()
31 profile.loadPreferences(profile.getPreferencePath())
32 if options.profile is not None:
33 profile.setProfileFromString(options.profile)
34 elif options.profileini is not None:
35 profile.loadProfile(options.profileini)
37 profile.loadProfile(profile.getDefaultProfilePath())
39 if options.printfile is not None:
40 from Cura.gui import printWindow
41 printWindow.startPrintInterface(options.printfile)
42 elif options.slice is not None:
43 from Cura.util import sliceEngine
44 from Cura.util import objectScene
45 from Cura.util import meshLoader
48 def commandlineProgressCallback(progress, ready):
49 if progress >= 0 and not ready:
50 print 'Preparing: %d%%' % (progress * 100)
51 scene = objectScene.Scene()
52 scene.updateMachineDimensions()
53 slicer = sliceEngine.Slicer(commandlineProgressCallback)
54 for m in meshLoader.loadMeshes(args[0]):
56 slicer.runSlicer(scene)
58 profile.replaceGCodeTagsFromSlicer(slicer.getGCodeFilename(), slicer)
61 shutil.copyfile(slicer.getGCodeFilename(), options.output)
62 print 'GCode file saved : %s' % options.output
64 shutil.copyfile(slicer.getGCodeFilename(), args[0] + '.gcode')
65 print 'GCode file saved as: %s' % (args[0] + '.gcode')
69 from Cura.gui import app
70 app.CuraApp(args).MainLoop()
72 if __name__ == '__main__':