Kissable1089
Posts: 27
Joined: Wed Feb 08, 2023 1:18 pm

post processing variables

I know that you guys are working on documentation for the variables, and you've been providing some variables as needed.

I'm looking for some variables to help with file naming (I can pass them to a script and do what I need to do).

Ideally, I'd like "profile name", "quality", "default speed", and "estimated time".

Thanks :)
S3D-Jason
Posts: 1383
Joined: Sun May 31, 2015 6:01 am

Re: post processing variables

For total time you can use:

[total_build_time_minutes]
[total_build_time_seconds]

I don't think there's a variable for the currently selected quality level. But if you really wanted you could probably set your scripts to be controlled by the quality auto-configure category, then you could actually write custom comments in the scripts for each quality level.
Kissable1089
Posts: 27
Joined: Wed Feb 08, 2023 1:18 pm

Re: post processing variables

Any update on a variable list for v5?
Kissable1089
Posts: 27
Joined: Wed Feb 08, 2023 1:18 pm

Re: post processing variables

Bump >:D
linuxguygary
Posts: 2
Joined: Wed Mar 01, 2023 12:25 pm

Re: post processing variables

Hi folks

I'm looking for a way to control my Klipper based chamber fan , looking a the S3D gcode file I see it issues a marlin M106 S89 P2 to set the fan to the correct percentage.

But Klipper needs "SET_FAN_SPEED FAN=fan_name SPEED=x"

So using the REPLACE post processing I have tried the text below, using every permutation of [fan2_speed] that I can think of , with no results, the gcode gets replaced as expected, but apparently I have not yet found the correct variable name for [fan2_speed] .

{REPLACE "M106 S89 P2" "SET_FAN_SPEED FAN=chamber_cooling_fan SPEED="[fan2_speed]}


The gcode in the output file looks like SET_FAN_SPEED FAN=chamber_cooling_fan SPEED= with nothing after the =


Can anyone offer any help for this variable or does it even exist?

A full list of variable name would REALLY be helpful !


Thanks all
Last edited by linuxguygary on Mon Jun 12, 2023 5:31 pm, edited 1 time in total.
S3D-Jason
Posts: 1383
Joined: Sun May 31, 2015 6:01 am

Re: post processing variables

You can use [fan2_speed_percentage] or [fan2_speed_pwm] depending on if you want the 0-100 or 0-255 value. This assumes your fan is already set to use T2 (otherwise adjust the number in those variables).
linuxguygary
Posts: 2
Joined: Wed Mar 01, 2023 12:25 pm

Re: post processing variables

I guess I need a little syntax help , here's what I'm doing

{REPLACE "M106 S89 P2" "SET_FAN_SPEED FAN=chamber_cooling_fan SPEED="[fan2_speed_percentage]}

this does the replace, but still leaves the line without a value like: SET_FAN_SPEED FAN=chamber_cooling_fan SPEED=

the fan is defined as T2 fan type as environmental (not extruder mounted) although I have tested both with the same result. The Marlin M106 SXX P2 does show the correct fan index (P2)

So I have a couple of questions
  • Is it possible to do simple math e.g. [fan2_speed_percentage]/100 because Klipper expects 0-1 ie. .35 for 35%
  • Syntax for the replace command to replace the M106 SXX P2 command with a literal string and the fan percentage. Depending on what I set the fan to in the software, the replace command will do an S value from 0-255 and I'd like to just search for any value and then provide that value to the Klipper equivalent in [fan2_speed_percentage] REGEX? or ??
  • what is the syntax needed to get both the replacement string and the variable value?
    This is not correct: {REPLACE "M106 S89 P2" "SET_FAN_SPEED FAN=chamber_cooling_fan SPEED="[fan2_speed_percentage]}
Last edited by linuxguygary on Tue Jun 13, 2023 1:19 pm, edited 2 times in total.
S3D-Jason
Posts: 1383
Joined: Sun May 31, 2015 6:01 am

Re: post processing variables

The [fan2_speed_percentage] variable needs to be inside the double quotes.

Basically it should be {REPLACE "find text" "replace text"}. There shouldn't be anything after the 4th double quote besides the closing squiggly brace.
linuxguygary
Posts: 2
Joined: Wed Mar 01, 2023 12:25 pm

Re: post processing variables

Here's my test REPLACE line with only the variable in the replacement {REPLACE "M106 S89 P2" "[fan2_speed_percentage]"}

and here is the result, its interpreted as literal text, (never the variable value). The layer comment included just for context.

; layer 20, Z = 6.0600
[fan2_speed_percentage]

What am I missing?
S3D-Jason
Posts: 1383
Joined: Sun May 31, 2015 6:01 am

Re: post processing variables

Are you hoping to have this replace with different values throughout the gcode? I'm not sure that will work. Post-processing usually replaces text with a constant value.

If you want to use a dynamic value, you could try putting the command in the layer change script instead. Just add the following to the post layer change script:

SET_FAN_SPEED FAN=chamber_cooling_fan SPEED=[fan2_speed_percentage]

Return to “General Discussion and Tips”