chiark / gitweb /
Update firmwares to 13.12 to fix the acceleration planner bug. Add dialog on new...
[cura.git] / Cura / cura.py
index 6ea2989ab4cda61e7e76ab15f96a26dec46da7c5..c631a02ff3255bb598daab70bd3574c12ad190ce 100644 (file)
@@ -23,11 +23,14 @@ def main():
                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()
 
        profile.loadPreferences(profile.getPreferencePath())
        if options.profile is not None:
-               profile.loadProfileFromString(options.profile)
+               profile.setProfileFromString(options.profile)
        elif options.profileini is not None:
                profile.loadProfile(options.profileini)
        else:
@@ -40,12 +43,28 @@ def main():
                from Cura.util import sliceEngine
                from Cura.util import objectScene
                from Cura.util import meshLoader
+               import shutil
 
+               def commandlineProgressCallback(progress, ready):
+                       if progress >= 0 and not ready:
+                               print 'Preparing: %d%%' % (progress * 100)
                scene = objectScene.Scene()
-               slicer = sliceEngine.Slicer()
+               scene.updateMachineDimensions()
+               slicer = sliceEngine.Slicer(commandlineProgressCallback)
                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 Cura.gui import app
                app.CuraApp(args).MainLoop()