X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=Cura%2Fcura.py;h=701b93e64a07834705a376e8064308475f21e3fd;hb=16c67477c32e8c5cdff79d23347b0713e32ee1a3;hp=14dc53b1e5cb6ef968a08bb2228d077c569bea73;hpb=e3aae1e716a4461c38114188f61a08ea960cd25e;p=cura.git diff --git a/Cura/cura.py b/Cura/cura.py index 14dc53b1..701b93e6 100644 --- a/Cura/cura.py +++ b/Cura/cura.py @@ -3,69 +3,70 @@ This page is in the table of contents. ==Overview== ===Introduction=== -Cura is a GPL tool chain to forge a gcode skein for a model. Based on Skeinforge. - -The slicing code is the same as Skeinforge. But the UI has been revamped to be... sane. - +Cura is a AGPL tool chain to generate a GCode path for 3D printing. Older versions of Cura where based on Skeinforge. +Versions up from 13.05 are based on a C++ engine called CuraEngine. """ - from __future__ import absolute_import -import __init__ +__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License" -import sys -import platform from optparse import OptionParser -from util import profile -from util import sliceRun - -__author__ = 'Daid' -__credits__ = """ -Enrique Perez (perez_enrique@yahoo.com) -Adrian Bowyer -Brendan Erwin -Greenarrow -Ian England -John Gilmore -Jonwise -Kyle Corbitt -Michael Duffin -Marius Kintel -Nophead -PJR -Reece.Arnott -Wade -Xsainnz -Zach Hoeken - -Organizations: -Art of Illusion """ - -__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html' +from Cura.util import profile def main(): parser = OptionParser(usage="usage: %prog [options] .stl") - parser.add_option("-p", "--profile", action="store", type="string", dest="profile", help="Use these profile settings instead of loading current_profile.ini") - parser.add_option("-P", "--project", action="store_true", dest="openprojectplanner", help="Open the project planner") - parser.add_option("-r", "--print", action="store", type="string", dest="printfile", help="Open the printing interface, instead of the normal cura interface.") + parser.add_option("-i", "--ini", action="store", type="string", dest="profileini", + help="Load settings from a profile ini file") + parser.add_option("-r", "--print", action="store", type="string", dest="printfile", + help="Open the printing interface, instead of the normal cura interface.") + parser.add_option("-p", "--profile", action="store", type="string", dest="profile", + help="Internal option, do not use!") + parser.add_option("-s", "--slice", action="store_true", dest="slice", + help="Slice the given files instead of opening them in Cura") + parser.add_option("-o", "--output", action="store", type="string", dest="output", + help="path to write sliced file to") + (options, args) = parser.parse_args() - if options.profile != None: - profile.loadGlobalProfileFromString(options.profile) - if options.openprojectplanner != None: - from gui import projectPlanner - projectPlanner.main() - return - if options.printfile != None: - from gui import printWindow + + profile.loadPreferences(profile.getPreferencePath()) + if options.profile is not None: + profile.setProfileFromString(options.profile) + elif options.profileini is not None: + profile.loadProfile(options.profileini) + else: + profile.loadProfile(profile.getDefaultProfilePath()) + + if options.printfile is not None: + from Cura.gui import printWindow printWindow.startPrintInterface(options.printfile) - return + elif options.slice is not None: + from Cura.util import sliceEngine + from Cura.util import objectScene + from Cura.util import meshLoader + import shutil - if len( args ) > 0: - sliceRun.runSlice(args) + def commandlineProgessCallback(progress, ready): + if progress >= 0 and not ready: + print 'Preparing: %d%%' % (progress * 100) + scene = objectScene.Scene() + slicer = sliceEngine.Slicer(commandlineProgessCallback) + for m in meshLoader.loadMeshes(args[0]): + scene.add(m) + slicer.runSlicer(scene) + slicer.wait() + profile.replaceGCodeTagsFromSlicer(slicer.getGCodeFilename(), slicer) + + if options.output: + shutil.copyfile(slicer.getGCodeFilename(), options.output) + print 'GCode file saved : %s' % options.output + else: + shutil.copyfile(slicer.getGCodeFilename(), args[0] + '.gcode') + print 'GCode file saved as: %s' % (args[0] + '.gcode') + + slicer.cleanup() else: - from gui import mainWindow - mainWindow.main() + from Cura.gui import app + app.CuraApp(args).MainLoop() if __name__ == '__main__': main() -