Getting attributes in macros

Basic Information:

Printer Model: Customized E3NG
MCU / Printerboard: BTT Pico x2
Host / SBC OrangePi3Zero
klippy.log

klippy (24).log (1.5 MB)

Describe your issue:

I have a [extruder_stepper extruder1] section defined in my printer.cfg, and it has a rotation_distance of 22.6789511 defined there.

If I try to use this line in a macro:

{% set oldrot = printer.configfile.settings.extruder1.rotation_distance|float %}

I’ll basically end up with the error:

gcode.CommandError: Error evaluating ‘gcode_button TooFar:press_gcode’: jinja2.exceptions.UndefinedError: ‘dict object’ has no attribute ‘extruder1’

If I pull it out of the main extruder, ie:

{% set oldrot = printer.configfile.settings.extruder.rotation_distance|float %}

It works as expected. Am I trying to do something that isn’t supported?

I’m trying to write some runtime turtleneck type filament buffer macros.

Thanks.

I would expect that this should be printer.configfile.settings['extruder_stepper extruder1'].rotation_distance since that’s what you said you wanted to access, not a section named extruder1.

That did it! Thank you very much.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.