Python does not have a switch-case construct, but it does have if/elif/else statements.
-
1
Python does not have a switch-case construct, but it does have if/elif/else statements.
Thank you for you replies.
Does nobody know how the variable for layer height is called in cura?
What do you mean by "variable"? A python variable? There is not global python variable for the layer height in Cura.
There is a setting called "layer_height". To get its value, you would call the method getPropertyValue on the "global stack".
global_stack = Application.getInstance().getGlobalContainerStack()
layer_height = global_stack.getProperty("layer_height", "value")
For future reference, you can find all setting names here:
http://files.fieldofview.com/cura/Replacement_Patterns.html
Just remove the { and } in the first column.
16 hours ago, ahoeben said:What do you mean by "variable"? A python variable? There is not global python variable for the layer height in Cura.
There is a setting called "layer_height". To get its value, you would call the method getPropertyValue on the "global stack".
global_stack = Application.getInstance().getGlobalContainerStack() layer_height = global_stack.getProperty("layer_height", "value")
Thanks, I could definitely use that at some point!
What would the spelling look like for "material_standby_temperature"?
Global_stack.getProperty (material_standby_temperature, value) returns only the default value of fdmprinter.def.json.
It would be best if extruders were also possible dependent!
26 minutes ago, zerspaner_gerd said:Global_stack.getProperty (material_standby_temperature, value) returns only the default value of fdmprinter.def.json.
That is because material_standby_temperature is set per extruder, so instead of the global stack you need to look at one of the extruder stacks.
For example, this gets the standby temperature set for the first extruder:
first_extruder_stack = ExtruderManager.getInstance().getActiveExtruderStacks()[0]
material_standby_temperature = first_extruder_stack.getProperty("material_standby_temperature", "value")
Excuse me @ahoeben ?,
has changed a bit with Cura 3.5.1, it does not work anymore.
t0_extruder_stack = ExtruderManager.getInstance().getActiveExtruderStacks()[0]
The post processing plugin is not displayed at all, if I hide it it will appear again for selection.
I tried a lot, without success. I do not know where to read up something.
Check cura.log in Help -> Show configuration folder. Search for the id (filename without .py) of your script, and it should give you a hint about why it is not loading. If not, I'm going to have to see the entire script.
2018-10-25 23:29:12,563 - ERROR - [MainThread] UM.Logger.logException [84]: Exception: Exception occurred while loading post processing plugin: list index out of range
2018-10-25 23:29:12,565 - ERROR - [MainThread] UM.Logger.logException [88]: Traceback (most recent call last):
2018-10-25 23:29:12,566 - ERROR - [MainThread] UM.Logger.logException [88]: File "C:\Program Files\Ultimaker Cura 3.5\plugins\PostProcessingPlugin\PostProcessingPlugin.py", line 155, in loadScripts
2018-10-25 23:29:12,567 - ERROR - [MainThread] UM.Logger.logException [88]: temp_object = loaded_class()
2018-10-25 23:29:12,568 - ERROR - [MainThread] UM.Logger.logException [88]: File "C:\Program Files\Ultimaker Cura 3.5\plugins\PostProcessingPlugin\scripts\test2_settings_cura.py", line 22, in __init__
2018-10-25 23:29:12,569 - ERROR - [MainThread] UM.Logger.logException [88]: self.t0_extruder_stack = ExtruderManager.getInstance().getActiveExtruderStacks()[0]
2018-10-25 23:29:12,570 - ERROR - [MainThread] UM.Logger.logException [88]: IndexError: list index out of range
It had worked with Cura 3.4.
Have now changed the order, now it seems to work again!
That was my previous one sequence:
from ..Script import Script from UM.Application import Application from cura.Settings.ExtruderManager import ExtruderManager import re class test2_settings_cura(Script): version = "1.0.0" def __init__(self): super().__init__() ######################################################################################################################## self.global_stack = Application.getInstance().getGlobalContainerStack() self.t0_extruder_stack = ExtruderManager.getInstance().getActiveExtruderStacks()[0] self.t1_extruder_stack = ExtruderManager.getInstance().getActiveExtruderStacks()[1] ######################################################################################################################## def getSettingDataString(self): return """{ "name":"Test Settings Cura """ + self.version + """", "key": "test2_settings_cura", "metadata": {}, "version": 2, "settings": { } }""" def execute(self, data): layers_started = False ######################################################################################################################## layer_height = self.global_stack.getProperty("layer_height", "value") Turm = self.global_stack.getProperty("prime_tower_position_x", "value") flover = self.global_stack.getProperty("machine_gcode_flavor", "value") material_standby_temperature_T0 = self.t0_extruder_stack.getProperty("material_standby_temperature", "value") material_standby_temperature_T1 = self.t1_extruder_stack.getProperty("material_standby_temperature", "value") ######################################################################################################################## for layer in data: modified_layer = "" index = data.index(layer) lines = layer.split("\n") for line in lines: if ";Generated with Cura_SteamEngine " in line: modified_layer += ";With Dual Script RepRap Duet3D V%s\n" % self.version + line +"\n\n" modified_layer += ";TES TESTE Layer:%f\n\n" % layer_height modified_layer += ";TES TESTE tover pos.x:%f\n\n" % Turm modified_layer += ";TES TESTE flover:%s\n\n" % flover modified_layer += ";TES TESTE Standby_T0:%s\n\n" % material_standby_temperature_T0 modified_layer += ";TES TESTE Standby_T1:%s\n\n" % material_standby_temperature_T1 layers_started = True continue if not layers_started: #insert original line modified_layer += line + "\n" continue else: #insert original line if line == "": modified_layer += line else: modified_layer += line + "\n" #replace the layer with the modified data data[index] = modified_layer return data
No matter you, now it works again
Thanks
Without looking too much into the rest of the code, you are looking up the stacks in the __init__ method. That method gets called when the PostProcessing script discovers the available scripts, which might be before Cura has finished loading the printers from your configuration. Even if it worked, the information would also be incorrect once you changed to another printer in Cura.
Don't do postprocessing things in __init__, but do them in execute.
Recommended Posts
taconite 1
Thank you for your reply
I already did that but couldn't find a switch-case style or if-statement but anyhow because it is just python I will figure it out (I hope so).
But does anyone know how the variable for the layer height is called?
Link to post
Share on other sites