Ejemplo n.º 1
0
    def onTimer(self, e):
        #Check if there is something in the clipboard
        profileString = ""
        try:
            if not wx.TheClipboard.IsOpened():
                if not wx.TheClipboard.Open():
                    return
                do = wx.TextDataObject()
                if wx.TheClipboard.GetData(do):
                    profileString = do.GetText()
                wx.TheClipboard.Close()

                startTag = "CURA_PROFILE_STRING:"
                if startTag in profileString:
                    #print "Found correct syntax on clipboard"
                    profileString = profileString.replace("\n", "").strip()
                    profileString = profileString[profileString.find(startTag
                                                                     ) +
                                                  len(startTag):]
                    if profileString != self.lastTriedClipboard:
                        print profileString
                        self.lastTriedClipboard = profileString
                        profile.setProfileFromString(profileString)
                        self.scene.notification.message(
                            "Loaded new profile from clipboard.")
                        self.updateProfileToAllControls()
        except:
            print "Unable to read from clipboard"
Ejemplo n.º 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 (*%s)|*%s;*%s" %
            (profile.getGCodeExtension(), profile.getGCodeExtension(),
             profile.getGCodeExtension()[0:2]))
        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.setProfileFromString(line[line.find(':') +
                                                      1:].strip())

                    if ';{profile_string}' not in profile.getAlterationFile(
                            'end.gcode'):
                        profile.setAlterationFile(
                            'end.gcode',
                            profile.getAlterationFile('end.gcode') +
                            '\n;{profile_string}')
                    hasProfile = True
            if hasProfile:
                self.updateProfileToAllControls()
            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()
Ejemplo n.º 3
0
	def onTimer(self, e):
		#Check if there is something in the clipboard
		profileString = ""
		try:
			if not wx.TheClipboard.IsOpened():
				if not wx.TheClipboard.Open():
					return
				do = wx.TextDataObject()
				if wx.TheClipboard.GetData(do):
					profileString = do.GetText()
				wx.TheClipboard.Close()

				startTag = "CURA_PROFILE_STRING:"
				if startTag in profileString:
					#print "Found correct syntax on clipboard"
					profileString = profileString.replace("\n","").strip()
					profileString = profileString[profileString.find(startTag)+len(startTag):]
					if profileString != self.lastTriedClipboard:
						print profileString
						self.lastTriedClipboard = profileString
						profile.setProfileFromString(profileString)
						self.scene.notification.message("Loaded new profile from clipboard.")
						self.updateProfileToAllControls()
		except:
			print "Unable to read from clipboard"
Ejemplo n.º 4
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 (*%s)|*%s;*%s"
         % (profile.getGCodeExtension(), profile.getGCodeExtension(), profile.getGCodeExtension()[0:2])
     )
     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.setProfileFromString(line[line.find(":") + 1 :].strip())
                 if ";{profile_string}" not in profile.getAlterationFile("end.gcode"):
                     profile.setAlterationFile(
                         "end.gcode", profile.getAlterationFile("end.gcode") + "\n;{profile_string}"
                     )
                 hasProfile = True
         if hasProfile:
             self.updateProfileToAllControls()
         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()
Ejemplo n.º 5
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")
	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.setProfileFromString(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 commandlineProgressCallback(progress, ready):
			if progress >= 0 and not ready:
				print 'Preparing: %d%%' % (progress * 100)
		scene = objectScene.Scene()
		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()
Ejemplo n.º 6
0
	def _load_profile_from_data(self, gcodeFile):
		for line in gcodeFile:
			if type(line) is tuple:
				line = line[0]

			if ';' in line:
				comment = line[line.find(';')+1:].strip()
				if comment.startswith('CURA_PROFILE_STRING:'):
					original_profile = profile.getProfileString()
					profile_string=comment[len('CURA_PROFILE_STRING:'):]
					profile.setProfileFromString(profile_string)
					self._load_profile_settings()
					profile.setProfileFromString(original_profile)
					break
Ejemplo n.º 7
0
    def _load_profile_from_data(self, gcodeFile):
        for line in gcodeFile:
            if type(line) is tuple:
                line = line[0]

            if ';' in line:
                comment = line[line.find(';') + 1:].strip()
                if comment.startswith('CURA_PROFILE_STRING:'):
                    original_profile = profile.getProfileString()
                    profile_string = comment[len('CURA_PROFILE_STRING:'):]
                    profile.setProfileFromString(profile_string)
                    self._load_profile_settings()
                    profile.setProfileFromString(original_profile)
                    break
Ejemplo n.º 8
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.setProfileFromString(line[line.find(':')+1:].strip())
					hasProfile = True
			if hasProfile:
				self.updateProfileToAllControls()
			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()
Ejemplo n.º 9
0
	def onTimer(self, e):
		#Check if there is something in the clipboard
		profileString = ""
		try:
			if not wx.TheClipboard.IsOpened():
				wx.TheClipboard.Open()
				do = wx.TextDataObject()
				if wx.TheClipboard.GetData(do):
					profileString = do.GetText()
				wx.TheClipboard.Close()

				if "CURA_PROFILE_STRING:" in profileString:
					#print "Found correct syntax on clipboard"
					profileString = profileString.replace("\n","")
					profileString = profileString.replace("CURA_PROFILE_STRING:", "")
					if profileString != self.lastTriedClipboard:
						self.lastTriedClipboard = profileString
						profile.setProfileFromString(profileString)
						print "changed profile"
						self.updateProfileToAllControls()
		except:
			print "Unable to read from clipboard"
Ejemplo n.º 10
0
def main():
    """
    Main Cura entry point. Parses arguments, and starts GUI or slicing process depending on the arguments.
    """
    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")
    parser.add_option("-o", "--output", action="store", type="string", dest="output",
        help="path to write sliced file to")
    parser.add_option("--serialCommunication", action="store", type="string", dest="serialCommunication",
        help="Start commandline serial monitor")

    (options, args) = parser.parse_args()

    if options.serialCommunication:
        from Cura import serialCommunication
        port, baud = options.serialCommunication.split(':')
        serialCommunication.startMonitor(port, baud)
        return

    print "load preferences from " + profile.getPreferencePath()
    profile.loadPreferences(profile.getPreferencePath())

    if options.profile is not None:
        profile.setProfileFromString(options.profile)
    elif options.profileini is not None:
        profile.loadProfile(options.profileini)
    else:
        profile.loadProfile(profile.getDefaultProfilePath(), True)

    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 commandlineProgressCallback(progress):
            if progress >= 0:
                #print 'Preparing: %d%%' % (progress * 100)
                pass
        scene = objectScene.Scene()
        scene.updateMachineDimensions()
        engine = sliceEngine.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] + profile.getGCodeExtension()
        with open(options.output, "wb") as f:
            gcode = engine.getResult().getGCode()
            while True:
                data = gcode.read()
                if len(data) == 0:
                    break
                f.write(data)
        print 'GCode file saved : %s' % options.output

        engine.cleanup()
    else:
        from Cura.gui import app
        app.CuraApp(args).MainLoop()
Ejemplo n.º 11
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")
    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.setProfileFromString(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()

        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()
Ejemplo n.º 12
0
def main():
    """
	Main Cura entry point. Parses arguments, and starts GUI or slicing process depending on the arguments.
	"""
    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")
    parser.add_option("-o",
                      "--output",
                      action="store",
                      type="string",
                      dest="output",
                      help="path to write sliced file to")
    parser.add_option("--serialCommunication",
                      action="store",
                      type="string",
                      dest="serialCommunication",
                      help="Start commandline serial monitor")

    (options, args) = parser.parse_args()

    if options.serialCommunication:
        from Cura import serialCommunication
        port, baud = options.serialCommunication.split(':')
        serialCommunication.startMonitor(port, baud)
        return

    print("load preferences from " + profile.getPreferencePath())
    profile.loadPreferences(profile.getPreferencePath())

    if options.profile is not None:
        profile.setProfileFromString(options.profile)
    elif options.profileini is not None:
        profile.loadProfile(options.profileini)
    else:
        profile.loadProfile(profile.getDefaultProfilePath(), True)

    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 commandlineProgressCallback(progress):
            if progress >= 0:
                #print 'Preparing: %d%%' % (progress * 100)
                pass

        scene = objectScene.Scene()
        scene.updateMachineDimensions()
        engine = sliceEngine.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] + profile.getGCodeExtension()
        with open(options.output, "wb") as f:
            gcode = engine.getResult().getGCode()
            while True:
                data = gcode.read()
                if len(data) == 0:
                    break
                f.write(data)
        print('GCode file saved : %s' % options.output)

        engine.cleanup()
    else:
        from Cura.gui import app
        app.CuraApp(args).MainLoop()