chiark / gitweb /
Copyright message needs to be after the __future__ imports.
[cura.git] / Cura / cura.py
1 #!/usr/bin/python
2 """
3 This page is in the table of contents.
4 ==Overview==
5 ===Introduction===
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.
8 """
9 from __future__ import absolute_import
10 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
11
12 from optparse import OptionParser
13
14 from Cura.util import profile
15
16 def main():
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         (options, args) = parser.parse_args()
27
28         profile.loadPreferences(profile.getPreferencePath())
29         if options.profile is not None:
30                 profile.loadProfileFromString(options.profile)
31         elif options.profileini is not None:
32                 profile.loadProfile(options.profileini)
33         else:
34                 profile.loadProfile(profile.getDefaultProfilePath())
35
36         if options.printfile is not None:
37                 from Cura.gui import printWindow
38                 printWindow.startPrintInterface(options.printfile)
39         elif options.slice is not None:
40                 from Cura.util import sliceEngine
41                 from Cura.util import objectScene
42                 from Cura.util import meshLoader
43
44                 scene = objectScene.Scene()
45                 slicer = sliceEngine.Slicer()
46                 for m in meshLoader.loadMeshes(args[0]):
47                         scene.add(m)
48                 slicer.runSlicer(scene)
49         else:
50                 from Cura.gui import app
51                 app.CuraApp(args).MainLoop()
52
53 if __name__ == '__main__':
54         main()