From f24e1da934a27e7b7a564e1de1adbcebaaef142d Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 19 Apr 2018 09:17:20 +0200 Subject: [PATCH] Always update job name for gcode files CURA-5246 --- cura/PrintInformation.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cura/PrintInformation.py b/cura/PrintInformation.py index d0e9e43e3f..1d66916b52 100644 --- a/cura/PrintInformation.py +++ b/cura/PrintInformation.py @@ -323,16 +323,21 @@ class PrintInformation(QObject): # when a file is opened using the terminal; the filename comes from _onFileLoaded and still contains its # extension. This cuts the extension off if necessary. name = os.path.splitext(name)[0] + filename_parts = os.path.basename(base_name).split(".") + + # If it's a gcode, also always update the job name + is_gcode = False + if len(filename_parts) > 1: + # Only check the extension(s) + is_gcode = "gcode" in filename_parts[1:] # if this is a profile file, always update the job name # name is "" when I first had some meshes and afterwards I deleted them so the naming should start again is_empty = name == "" - if is_project_file or (is_empty or (self._base_name == "" and self._base_name != name)): - # remove ".curaproject" suffix from (imported) the file name - if name.endswith(".curaproject"): - name = name[:name.rfind(".curaproject")] - self._base_name = name - self._updateJobName() + if is_gcode or is_project_file or (is_empty or (self._base_name == "" and self._base_name != name)): + # Only take the file name part + self._base_name = filename_parts[0] + self._updateJobName() @pyqtProperty(str, fset = setBaseName, notify = baseNameChanged) def baseName(self):