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 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
11 from optparse import OptionParser
13 from Cura.util import profile
16 parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
17 parser.add_option("-i", "--ini", action="store", type="string", dest="profileini",
18 help="Load settings from a profile ini file")
19 parser.add_option("-r", "--print", action="store", type="string", dest="printfile",
20 help="Open the printing interface, instead of the normal cura interface.")
21 parser.add_option("-p", "--profile", action="store", type="string", dest="profile",
22 help="Internal option, do not use!")
23 parser.add_option("-s", "--slice", action="store_true", dest="slice",
24 help="Slice the given files instead of opening them in Cura")
25 parser.add_option("-o", "--output", action="store", type="string", dest="output",
26 help="path to write sliced file to")
27 parser.add_option("--serialCommunication", action="store", type="string", dest="serialCommunication",
28 help="Start commandline serial monitor")
30 (options, args) = parser.parse_args()
32 if options.serialCommunication:
33 from Cura import serialCommunication
34 serialCommunication.startMonitor(options.serialCommunication)
37 print "load preferences from " + profile.getPreferencePath()
38 profile.loadPreferences(profile.getPreferencePath())
40 if options.profile is not None:
41 profile.setProfileFromString(options.profile)
42 elif options.profileini is not None:
43 profile.loadProfile(options.profileini)
45 profile.loadProfile(profile.getDefaultProfilePath())
47 if options.printfile is not None:
48 from Cura.gui import printWindow
49 printWindow.startPrintInterface(options.printfile)
50 elif options.slice is not None:
51 from Cura.util import sliceEngine
52 from Cura.util import objectScene
53 from Cura.util import meshLoader
56 def commandlineProgressCallback(progress):
58 #print 'Preparing: %d%%' % (progress * 100)
60 scene = objectScene.Scene()
61 scene.updateMachineDimensions()
62 engine = sliceEngine.Engine(commandlineProgressCallback)
63 for m in meshLoader.loadMeshes(args[0]):
65 engine.runEngine(scene)
68 if not options.output:
69 options.output = args[0] + '.gcode'
70 with open(options.output, "wb") as f:
71 f.write(engine.getResult().getGCode())
72 print 'GCode file saved : %s' % options.output
76 from Cura.gui import app
77 app.CuraApp(args).MainLoop()
79 if __name__ == '__main__':