chiark / gitweb /
Allow for odd shaped platforms and generalize the UM2 clip code into no-go zones.
[cura.git] / Cura / cura.py
index 73907642eff8eb18717d8978a5ebfb8126f7798f..701b93e64a07834705a376e8064308475f21e3fd 100644 (file)
@@ -3,45 +3,16 @@
 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
+__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
 
 from optparse import OptionParser
 
 from Cura.util import profile
 
-__author__ = 'Daid'
-__credits__ = """
-David Braam (daid303@gmail.com)
-Enrique Perez (perez_enrique@yahoo.com)
-Adrian Bowyer <http://forums.reprap.org/profile.php?12,13>
-Brendan Erwin <http://forums.reprap.org/profile.php?12,217>
-Greenarrow <http://forums.reprap.org/profile.php?12,81>
-Ian England <http://forums.reprap.org/profile.php?12,192>
-John Gilmore <http://forums.reprap.org/profile.php?12,364>
-Jonwise <http://forums.reprap.org/profile.php?12,716>
-Kyle Corbitt <http://forums.reprap.org/profile.php?12,90>
-Michael Duffin <http://forums.reprap.org/profile.php?12,930>
-Marius Kintel <http://reprap.soup.io/>
-Nophead <http://www.blogger.com/profile/12801535866788103677>
-PJR <http://forums.reprap.org/profile.php?12,757>
-Reece.Arnott <http://forums.reprap.org/profile.php?12,152>
-Wade <http://forums.reprap.org/profile.php?12,489>
-Xsainnz <http://forums.reprap.org/profile.php?12,563>
-Zach Hoeken <http://blog.zachhoeken.com/>
-Ilya Kulakov (kulakov.ilya@gmail.com)
-
-Organizations:
-Ultimaker <http://www.ultimaker.com>
-Art of Illusion <http://www.artofillusion.org/>"""
-
-__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
-
-
 def main():
        parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
        parser.add_option("-i", "--ini", action="store", type="string", dest="profileini",
@@ -52,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:
@@ -69,21 +43,30 @@ def main():
                from Cura.util import sliceEngine
                from Cura.util import objectScene
                from Cura.util import meshLoader
+               import shutil
 
+               def commandlineProgessCallback(progress, ready):
+                       if progress >= 0 and not ready:
+                               print 'Preparing: %d%%' % (progress * 100)
                scene = objectScene.Scene()
-               slicer = sliceEngine.Slicer()
+               slicer = sliceEngine.Slicer(commandlineProgessCallback)
                for m in meshLoader.loadMeshes(args[0]):
                        scene.add(m)
                slicer.runSlicer(scene)
-       else:
-               #Place any unused arguments as last file, so Cura starts with opening those files.
-               if len(args) > 0:
-                       profile.putPreference('lastFile', ';'.join(args))
-                       profile.setPluginConfig([])
+               slicer.wait()
+               profile.replaceGCodeTagsFromSlicer(slicer.getGCodeFilename(), slicer)
 
-               #Do not import anything from Cura.gui before this spot, as the above code also needs to run in pypy.
+               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().MainLoop()
+               app.CuraApp(args).MainLoop()
 
 if __name__ == '__main__':
        main()