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 print "load preferences from " + profile.getPreferencePath()
32 profile.loadPreferences(profile.getPreferencePath())
34 if options.profile is not None:
35 profile.setProfileFromString(options.profile)
36 elif options.profileini is not None:
37 profile.loadProfile(options.profileini)
39 profile.loadProfile(profile.getDefaultProfilePath())
41 if options.printfile is not None:
42 from Cura.gui import printWindow
43 printWindow.startPrintInterface(options.printfile)
44 elif options.slice is not None:
45 from Cura.util import sliceEngine
46 from Cura.util import objectScene
47 from Cura.util import meshLoader
50 def commandlineProgressCallback(progress, ready):
51 if progress >= 0 and not ready:
52 print 'Preparing: %d%%' % (progress * 100)
53 scene = objectScene.Scene()
54 scene.updateMachineDimensions()
55 slicer = sliceEngine.Slicer(commandlineProgressCallback)
56 for m in meshLoader.loadMeshes(args[0]):
58 slicer.runSlicer(scene)
60 profile.replaceGCodeTagsFromSlicer(slicer.getGCodeFilename(), slicer)
63 shutil.copyfile(slicer.getGCodeFilename(), options.output)
64 print 'GCode file saved : %s' % options.output
66 shutil.copyfile(slicer.getGCodeFilename(), args[0] + '.gcode')
67 print 'GCode file saved as: %s' % (args[0] + '.gcode')
71 from Cura.gui import app
72 app.CuraApp(args).MainLoop()
74 if __name__ == '__main__':