Пример #1
0
	def OnLoadProfileFromGcode(self, e):
		dlg=wx.FileDialog(self, language.getText("Select gcode file to load profile from"), os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
		dlg.SetWildcard("gcode files (*.gcode)|*.gcode;*.g")
		if dlg.ShowModal() == wx.ID_OK:
			gcodeFile = dlg.GetPath()
			f = open(gcodeFile, 'r')
			hasProfile = False
			for line in f:
				if line.startswith(';CURA_PROFILE_STRING:'):
					profile.loadProfileFromString(line[line.find(':')+1:].strip())
					hasProfile = True
			if hasProfile:
				self.updateProfileToControls()
			else:
				wx.MessageBox(language.getText('No profile found in GCode file.\nThis feature only works with GCode files made by Cura 12.07 or newer.'), language.getText('Profile load error'), wx.OK | wx.ICON_INFORMATION)
		dlg.Destroy()
Пример #2
0
	def OnLoadProfileFromGcode(self, e):
		dlg=wx.FileDialog(self, "Select gcode file to load profile from", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
		dlg.SetWildcard("gcode files (*.gcode)|*.gcode;*.g")
		if dlg.ShowModal() == wx.ID_OK:
			gcodeFile = dlg.GetPath()
			f = open(gcodeFile, 'r')
			hasProfile = False
			for line in f:
				if line.startswith(';CURA_PROFILE_STRING:'):
					profile.loadProfileFromString(line[line.find(':')+1:].strip())
					hasProfile = True
			if hasProfile:
				self.updateProfileToControls()
			else:
				wx.MessageBox('No profile found in GCode file.\nThis feature only works with GCode files made by Cura 12.07 or newer.', 'Profile load error', wx.OK | wx.ICON_INFORMATION)
		dlg.Destroy()
Пример #3
0
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="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")
    (options, args) = parser.parse_args()

    profile.loadPreferences(profile.getPreferencePath())
    if options.profile is not None:
        profile.loadProfileFromString(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)
    elif options.slice is not None:
        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(commandlineProgessCallback)
        for m in meshLoader.loadMeshes(args[0]):
            scene.add(m)
        slicer.runSlicer(scene)
        slicer.wait()
        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()