GcodeFilenameFormat icon indicating copy to clipboard operation
GcodeFilenameFormat copied to clipboard

[base_name] create duplicate text if after saving you will reslice and save again

Open giancarlodomanico opened this issue 1 year ago • 0 comments

Hi, I have experimented that if you use [base_name] in the template you can get duplicate text in your file name. Try it :

  1. load stl file
  2. slice it
  3. save it having [base_name] in the template
  4. change samething in the print settings
  5. slice again
  6. save again and you will get all the template duplicated.

I have fixed it changing in this way the file ParseFileFormat.py but I'm not expert of Cure and Python too, so I think that will be a better way to do it.

import re from UM.Logger import Logger #Adding messages to the log.

Substitute print setting values in filename format

def parseFilenameFormat(print_settings, filename_format): base_name = print_settings["base_name"] job_name = print_settings["job_name"] Logger.log("d", "base_name %s", base_name) Logger.log("d", "job_name %s", job_name) no_base_name_format = filename_format no_base_name_format = no_base_name_format.replace("[base_name]", "") no_base_name_format = no_base_name_format.replace("[job_name]", "")

for setting, value in print_settings.items():
    filename_format = filename_format.replace("[" + setting + "]", str(value))
    no_base_name_format = no_base_name_format.replace("[" + setting + "]", str(value))            

no_base_name_format = re.sub('[^A-Za-z0-9.,_\-%°$£€#\[\]\(\)\|\+\'\" ]+', '', no_base_name_format)
filename = re.sub('[^A-Za-z0-9.,_\-%°$£€#\[\]\(\)\|\+\'\" ]+', '', filename_format)

Logger.log("d", "no_base_name_format %s", no_base_name_format)
Logger.log("d", "filename %s", filename)
if no_base_name_format in base_name:
    filename = base_name

return filename   

giancarlodomanico avatar Apr 13 '23 18:04 giancarlodomanico