Jump to content

Cuq

Expert
  • Posts

    677
  • Joined

  • Last visited

  • Days Won

    19

Everything posted by Cuq

  1. For the the majority of these parameters ( material_print_temperature, machine_nozzle_size , material_diameter etc ) . GetProperty function retrun the right values. GetVal = Application.getInstance().getGlobalContainerStack().getProperty("machine_nozzle_size", "value") But I don't find any parameter for the profil name and the material base. GetValStr = Application.getInstance().getGlobalContainerStack().extruders[0].material.getMetaData().get("material", "") Doesn't seems to be a valide solution
  2. Hello, I'm trying to create my own postprocessing script. The goal of the script is to add at the beginning of the GCode file different comments to keep the print profile. For the print parameter I don't have anny problem to get the values , but I don"t know how to get the Name of the profile and the initial material name. I'have made a test with a command line like : GetValStr = Application.getInstance().getGlobalContainerStack().material.getMetaData().get("material", "") but this line return an empty value. hereafter the actual sample code import re #To perform the search and replace. from ..Script import Script from UM.Application import Application #To get the current printer's settings. ## Performs a search-and-replace on all g-code. # # Due to technical limitations, the search can't cross the border between layers. class Documentation(Script): def getSettingDataString(self): return """{ "name": "Documentation parametres", "key": "Documentation", "metadata": {}, "version": 2, "settings": { "search": { "label": "Search", "description": "All occurrences of this text will get replaced by the parameter list.", "type": "str", "default_value": ";FLAVOR:Marlin" } } }""" def execute(self, data): search_string = self.getSettingValueByKey("search") search_regex = re.compile(search_string) replace_string = search_string replace_string = replace_string + "\n;==============================================\n; Documentation\n;==============================================" # machine_nozzle_size GetVal = Application.getInstance().getGlobalContainerStack().getProperty("machine_nozzle_size", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("machine_nozzle_size", "label") replace_string = replace_string + "\n; " + GetLabel + " : {Val} mm".format(Val = GetVal) # material_guid GetValStr = Application.getInstance().getGlobalContainerStack().material.getMetaData().get("material", "") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("material_guid", "label") replace_string = replace_string + "\n; " + GetLabel + " : " + GetValStr # layer_height GetVal = Application.getInstance().getGlobalContainerStack().getProperty("layer_height", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("layer_height", "label") replace_string = replace_string + "\n; " + GetLabel + " : {Val} mm".format(Val = GetVal) # line_width GetVal = Application.getInstance().getGlobalContainerStack().getProperty("line_width", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("line_width", "label") replace_string = replace_string + "\n; " + GetLabel + " : {Val} mm".format(Val = GetVal) # material_print_temperature GetVal = Application.getInstance().getGlobalContainerStack().getProperty("material_print_temperature", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("material_print_temperature", "label") replace_string = replace_string + "\n; " + GetLabel + " : {Val}°C".format(Val = GetVal) # speed_print GetVal = Application.getInstance().getGlobalContainerStack().getProperty("speed_print", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("speed_print", "label") replace_string = replace_string + "\n; " + GetLabel + " : {Val} mm/s".format(Val = GetVal) # speed_infill GetVal = Application.getInstance().getGlobalContainerStack().getProperty("speed_infill", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("speed_infill", "label") replace_string = replace_string + "\n; " + GetLabel + " : {Val} mm/s".format(Val = GetVal) # material_flow GetVal = Application.getInstance().getGlobalContainerStack().getProperty("material_flow", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("material_flow", "label") replace_string = replace_string + "\n; " + GetLabel + " : {Val} %".format(Val = GetVal) # retraction_enable GetVal = Application.getInstance().getGlobalContainerStack().getProperty("retraction_enable", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("retraction_enable", "label") replace_string = replace_string + "\n; " + GetLabel + " : [{Val}]".format(Val = GetVal) # retraction_speed GetVal = Application.getInstance().getGlobalContainerStack().getProperty("retraction_speed", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("retraction_speed", "label") replace_string = replace_string + "\n; " + GetLabel + " : {Val}".format(Val = GetVal) # support_enable GetVal = Application.getInstance().getGlobalContainerStack().getProperty("support_enable", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("support_enable", "label") replace_string = replace_string + "\n; " + GetLabel + " : [{Val}]".format(Val = GetVal) # support_type GetValStr = Application.getInstance().getGlobalContainerStack().getProperty("support_type", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("support_type", "label") replace_string = replace_string + "\n; " + GetLabel + " : " + GetValStr # infill_sparse_density GetVal = Application.getInstance().getGlobalContainerStack().getProperty("infill_sparse_density", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("infill_sparse_density", "label") replace_string = replace_string + "\n; " + GetLabel + " : {Val} %".format(Val = GetVal) # infill_pattern GetValStr = Application.getInstance().getGlobalContainerStack().getProperty("infill_pattern", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("infill_pattern", "label") replace_string = replace_string + "\n; " + GetLabel + " : " + GetValStr # material_diameter GetVal = Application.getInstance().getGlobalContainerStack().getProperty("material_diameter", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("material_diameter", "label") replace_string = replace_string + "\n; " + GetLabel + " : {Val} mm".format(Val = GetVal) # ironing_enabled GetVal = Application.getInstance().getGlobalContainerStack().getProperty("ironing_enabled", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("ironing_enabled", "label") replace_string = replace_string + "\n; " + GetLabel + " : [{Val}]".format(Val = GetVal) # adhesion_type GetValStr = Application.getInstance().getGlobalContainerStack().getProperty("adhesion_type", "value") GetLabel = Application.getInstance().getGlobalContainerStack().getProperty("adhesion_type", "label") replace_string = replace_string + "\n; " + GetLabel + " : " + GetValStr # Fin de commentaire replace_string = replace_string + "\n;==============================================" for layer_number, layer in enumerate(data): data[layer_number] = re.sub(search_regex, replace_string, layer) #Replace all. return data
×
×
  • Create New...