def __init__(self, files): from Cura.util import resources from Cura.util import version brand = version.getBrand() resources.setupLocalization(brand) if not version.isDevVersion(): super(CuraApp, self).__init__(redirect = True, filename = 'output.txt') else: super(CuraApp, self).__init__(redirect = False) self.mainWindow = None self.splash = None self.loadFiles = files # if sys.platform.startswith('darwin'): # Do not show a splashscreen on OSX, as by Apple guidelines # self.afterSplashCallback() # else: from Cura.gui import splashScreen self.splash = splashScreen.splashScreen(self.afterSplashCallback)
def main(): parser = OptionParser(usage="usage: %prog [options] <filename>.stl") 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="append", 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 is not None: # profile.loadGlobalProfileFromString(options.profile) if options.profile is not None: for option in options.profile: (setting, arg) = option.split("=") profile.putProfileSetting(setting, arg) if options.profileini is not None: profile.loadGlobalProfile(options.profileini) if options.printfile is not None: from Cura.gui import printWindow printWindow.startPrintInterface(options.printfile) elif options.slice is not None: from Cura.util import sliceEngine2 from Cura.util import objectScene from Cura.util import meshLoader from Cura.util import resources from Cura.util import version brand = version.getBrand() resources.setupLocalization(brand) def commandlineProgressCallback(progress): if progress >= 0: print 'Preparing: %d%%' % (progress * 100) pass scene = objectScene.Scene() engine = sliceEngine2.Engine(commandlineProgressCallback) for m in meshLoader.loadMeshes(args[0]): scene.add(m) engine.runEngine(scene) engine.wait() if not options.output: options.output = args[0] + '.gcode' with open(options.output, "wb") as f: gcode = engine.getResult().getGCode() while True: data = gcode.read() if len(data) == 0: break f.write(data) engine.cleanup() # from Cura.util import sliceRun # sliceRun.runSlice(args) else: #Place any unused arguments as last file, so Cura starts with opening those files. if len(args) > 0: profile.putPreference('lastFile', '^ '.join(args)) #Do not import anything from Cura.gui before this spot, as the above code also needs to run in pypy. from Cura.gui import app app.CuraApp(args).MainLoop()