Example #1
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()
Example #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()
 def loadFile(self, filename):
     self.textArea.SetValue(profile.getAlterationFile(filename))
	def loadFile(self, filename):
		self.textArea.SetValue(profile.getAlterationFile(filename))