def save(self, filename): """manage the saving of the file based on extension""" fn, ext = os.path.splitext(filename) ext = ext.lower() if ext == ".probe" or ext == ".xyz": # save probe if not self.gcode.probe.isEmpty(): self.gcode.probe.save(filename) if filename is not None: self._saveConfigFile() elif ext == ".orient": # save orientation file return self.gcode.orient.save(filename) elif ext == ".txt": # save gcode as txt: # only enabled blocks and no OKKCNC metadata or comments return self.gcode.saveNGC(filename, False) elif ext == ".okk": # save gcode with OKKCNC metadata return self.gcode.saveOKK(filename) elif ext == ".ngc": # save gcode with OKKCNC metadata and comments return self.gcode.saveNGC(filename, True) else: if filename is not None: self.gcode.filename = filename self._saveConfigFile() IniFile.add_recent_file(self.gcode.filename) return self.gcode.save()
def load(self, filename): """Load a file into editor""" fn, ext = os.path.splitext(filename) ext = ext.lower() if ext == ".probe": if filename is not None: self.gcode.probe.filename = filename self._saveConfigFile() self.gcode.probe.load(filename) elif ext == ".orient": # save orientation file self.gcode.orient.load(filename) else: self.gcode.load(filename) IniFile.add_recent_file(filename)