Skip to content

Update start_print.cfg with FORCE_MESH#407

Open
0rinsb3lt wants to merge 7 commits into
Frix-x:mainfrom
0rinsb3lt:main
Open

Update start_print.cfg with FORCE_MESH#407
0rinsb3lt wants to merge 7 commits into
Frix-x:mainfrom
0rinsb3lt:main

Conversation

@0rinsb3lt

Copy link
Copy Markdown

Added FORCE_MESH as a parameter to ADAPTIVE_BED_MESH

Added FORCE_MESH as a parameter to ADAPTIVE_BED_MESH
@Surion79

Copy link
Copy Markdown
Contributor

Can you elaborate the use case? Actually it is missing something. 1. I don't see the variable in variables.cfg.
2. is it an option for start_print as parameter within the slicer? That would be missing too

@Benoitone

Copy link
Copy Markdown
Contributor

Can you elaborate the use case? Actually it is missing something. 1. I don't see the variable in variables.cfg. 2. is it an option for start_print as parameter within the slicer? That would be missing too

I think he must add {% set force_mesh = params.FORCE_MESH|default(False) %} in the param from the slicer?

@Surion79

Surion79 commented Dec 19, 2023

Copy link
Copy Markdown
Contributor

He remarks an unknown user variable. So not sure of the integration. It would mean defaulting to the variable and not to a hard coded default.

@Benoitone

Copy link
Copy Markdown
Contributor

?

{% set force_mesh = params.FORCE_MESH|default(False) %} in the param from the slicer?
Is just set to a default variable?

@Surion79

Copy link
Copy Markdown
Contributor

?

{% set force_mesh = params.FORCE_MESH|default(False) %} in the param from the slicer? Is just set to a default variable?

no, that is setting to a default (hard coded) VALUE. not a default variable. Default variable is declared in his PR, but I was either blind or the variable is not available in variables.cfg

@0rinsb3lt

0rinsb3lt commented Dec 19, 2023

Copy link
Copy Markdown
Author

You are correct I didn't put it into variables.cfg. This PR is to give the user the option to force a bed mesh.
Most of the code was already there it just defaulted to False and never actually read from the variables.cfg file (User variables) or gave the end user a way to enable it.

I will update with a default variables_force_mesh: False in variables.cfg

Added variable_force_mesh with default False value

Gives the end user an option to dis/enable.
@Surion79

Copy link
Copy Markdown
Contributor

i would also like to have it as parameter in start_print available, if we are already integrating it

@0rinsb3lt

Copy link
Copy Markdown
Author

i would also like to have it as parameter in start_print available, if we are already integrating it

So that you could enable from the slicer?

@Surion79

Surion79 commented Dec 19, 2023

Copy link
Copy Markdown
Contributor

yes. you can look the start_print macro with PARAMS. and adapt it accordingly for bed mesh. I expect some integration since the bed mesh module which is a starting module was modified.

@Benoitone

Benoitone commented Dec 19, 2023

Copy link
Copy Markdown
Contributor

I don't really see the real point of adding another user variable with all the problems that can cause (when upgrading Klippain) for a function that has limited interest. Why make a bed mesh when the printed part is very small?
So in my opinion it could remain something marginal that the user would be able to pass into their slicer start g_code and which would be used here .

And in this case I don't see how replacing {% set force_mesh = printer["gcode_macro _USER_VARIABLES"].force_mesh %} by {% set force_mesh = params.FORCE_MESH|default(False) %} could cause a problem.

Finally, in the event that you absolutely want to add the new user variable entry in variables.cfg the description can easily lead to confusion: the way it is worded can make you think that there will be no bed mesh if you leave it on False...

@Surion79

Copy link
Copy Markdown
Contributor

the whole thing makes no sense since the addition is in the bed_mesh_module within the start print sequence. you either need to pass it through start_print params or through variables. if neither is done, the addition is plain never in use. Please look at the change. it is NOT done in the START_PRINT macro.

@Surion79

Copy link
Copy Markdown
Contributor

and i agree, the var wording creates more issues than it solves

@Frix-x Frix-x left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think this doesn't need a variable but rather a START_PRINT param as it is likely to be used based on the parts to be printed directly from the slicer profile and setting a variable for that is not a good usecase.

Also please note that since this parameter is originally designed to be used from the slicer (even if in Klippain it was a little bit forgotten), so it's not using a Jinja True/False value but a 0/1 instead.

I added some suggestions to make it ready for a merge :)

Comment thread macros/base/start_print.cfg Outdated
{% set FL_SIZE = printer["gcode_macro START_PRINT"].fl_size %}
{% set BED_MESH_PROFILE = printer["gcode_macro START_PRINT"].bed_mesh_profile %}

{% set force_mesh = printer["gcode_macro _USER_VARIABLES"].force_mesh %}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the variable and use this line instead?

Suggested change
{% set force_mesh = printer["gcode_macro _USER_VARIABLES"].force_mesh %}
{% set force_mesh = params.FORCE_MESH|default(0) %}

@Benoitone Benoitone Dec 19, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the variable and use this line instead?

Suggested change
{% set force_mesh = printer["gcode_macro _USER_VARIABLES"].force_mesh %}
{% set force_mesh = params.FORCE_MESH|default(0) %}

I think this params: {% set force_mesh = params.FORCE_MESH|default(0) %} must be parse in this section of print_start:
# Get all the parameters passed from the slicer

and call after in bed mesh module?
{% set FORCE_MESH = printer["gcode_macro START_PRINT"].force_mesh %}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not using the implementation style in start print like it is done previously all the time? the bed mesh module is never called directly outside start print

Comment thread user_templates/variables.cfg Outdated
Comment on lines +40 to +42
## Always force an adaptive bed mesh during the START_PRINT macro
variable_force_mesh: False

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this as it's not needed for this and would add more confusion since it would need a restart of Klipper each time you want to change it and it's not really flexible to configure it per print

Force Mesh in Start_Print with slicer params in Module capsulation
removed variable
@Surion79

Copy link
Copy Markdown
Contributor

i took the liberty to correct it directly. Should be fine now, since it is 100% matching Module coding

@Benoitone

Benoitone commented Dec 20, 2023

Copy link
Copy Markdown
Contributor

i took the liberty to correct it directly. Should be fine now, since it is 100% matching Module coding

It seems perfect for me...
@Surion79 @Frix-x : Just for my knowledge... is there a difference if we use False instead of 0 as the default value in this case?

@Surion79

Copy link
Copy Markdown
Contributor

i took the liberty to correct it directly. Should be fine now, since it is 100% matching Module coding

It seems perfect for me... @Surion79 @Frix-x : Just for my knowledge... is there a difference if we use False instead of 0 as the default value in this case?

i made it int, 0/1 as frix stated it in an above comment

@Benoitone

Copy link
Copy Markdown
Contributor

i took the liberty to correct it directly. Should be fine now, since it is 100% matching Module coding

It seems perfect for me... @Surion79 @Frix-x : Just for my knowledge... is there a difference if we use False instead of 0 as the default value in this case?

i made it int, 0/1 as frix stated it in an above comment

Because in

{% set force_mesh = params.FORCE_MESH|default(False) %} # force the mesh even if it's a small part (ie. computed less than 3x3)
it seems to be a boolean...

@Benoitone

Copy link
Copy Markdown
Contributor

And maybe take the opportunity to include this function in configuration.md... https://github.com/Frix-x/klippain/blob/e1a6cba3f009e8248b473754599ea1ad2f7bf8c1/docs/configuration.md

@Surion79

Copy link
Copy Markdown
Contributor

i took the liberty to correct it directly. Should be fine now, since it is 100% matching Module coding

It seems perfect for me... @Surion79 @Frix-x : Just for my knowledge... is there a difference if we use False instead of 0 as the default value in this case?

i made it int, 0/1 as frix stated it in an above comment

Because in

{% set force_mesh = params.FORCE_MESH|default(False) %} # force the mesh even if it's a small part (ie. computed less than 3x3)

it seems to be a boolean...

could you please comment the line directly in the PR? I don't see it in the current version of the PR

@Benoitone

Copy link
Copy Markdown
Contributor

i took the liberty to correct it directly. Should be fine now, since it is 100% matching Module coding

It seems perfect for me... @Surion79 @Frix-x : Just for my knowledge... is there a difference if we use False instead of 0 as the default value in this case?

i made it int, 0/1 as frix stated it in an above comment

Because in

{% set force_mesh = params.FORCE_MESH|default(False) %} # force the mesh even if it's a small part (ie. computed less than 3x3)

it seems to be a boolean...

could you please comment the line directly in the PR? I don't see it in the current version of the PR

I don't see how to do this on mobile app...
it's in macros/calibration/adaptive_bed_mesh.cfg -> Ligne67

@Surion79

Copy link
Copy Markdown
Contributor

oooh, you mean outside this PR. Silly me :D

@Frix-x regarding your statement of force_mesh being 0/1 and in bed mesh it was programmed true/false. Which way to go? Stay int, go boolean or switch from int to bool?

@Frix-x Frix-x left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i took the liberty to correct it directly. Should be fine now, since it is 100% matching Module coding

Be careful by doing this, I usually avoid it because it will commit and push directly on the user repo without its consentement and that could lead to troubles especially if it's pushing directly on his main branch like for this PR (ie. worst case is directly breaking his machine by pushing some bad code). Also I like to keep the commits authered by each users as possible as it's good to keep the authorship/copyright for them but it's also easier to find out who have made what on Klippain for us.

@Frix-x regarding your statement of force_mesh being 0/1 and in bed mesh it was programmed true/false. Which way to go? Stay int, go boolean or switch from int to bool?

Yes, I will need to test it. In Jinja, when a string like "False" is used, it can be very confusing because, as a string, it is non-null and thus evaluates as True in a boolean context. So I know that I got a lot of trouble with this in the past and remember that to make it work, I had to use FORCE_MESH=1 on my Prusa. But this need to be tested to be sure.

Finally I added two small change request:

  1. First one is a small error on the same subject that will make it not work so it needs to be changed if it's really an integer that needs to be used
  2. Second one is just to keep it well formated and coding style consistent (uppercase wanted)

Comment thread macros/base/start_print.cfg Outdated
Comment thread macros/base/start_print.cfg Outdated
Comment thread macros/base/start_print.cfg Outdated
Surion79 and others added 3 commits December 20, 2023 17:51
Co-authored-by: Félix Boisselier <[email protected]>
Co-authored-by: Félix Boisselier <[email protected]>
Co-authored-by: Félix Boisselier <[email protected]>
@Surion79 Surion79 requested a review from Frix-x December 20, 2023 16:51
@Surion79

Copy link
Copy Markdown
Contributor

understood and done. usually I don't do that :)

{% set MATERIAL = params.MATERIAL|default(printer["gcode_macro _USER_VARIABLES"].print_default_material)|string %} # Material type set in the slicer
{% set FL_SIZE = params.SIZE|default("0_0_0_0")|string %} # Get bounding box of the first layer for the adaptive bed mesh
{% set BED_MESH_PROFILE = params.MESH|default("")|string %} # Bed mesh profile to load
{% set FORCE_MESH = params.FORCE_MESH|default(0)|int %}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understant why int is better than boolean in this case?
when user pass the start_print parameter: FORCE_MESH=1 is interpreted as True, and with FORCE_MESH=0 is False??

Suggested change
{% set FORCE_MESH = params.FORCE_MESH|default(0)|int %}
{% set force_mesh = params.FORCE_MESH|default(False) %}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this should be the case, but as I said, I need to test it properly since Jinja and boolean is pretty finicky.

Here is why I prefer 0/1 from the slicer:

  1. If you put FORCE_MESH=False -> this should result in False so it's ok
  2. If you put FORCE_MESH="False" -> this will result is True since "False" is a non-null string so it will be very confusing and I'm not sure how the slicer will create the Gcode.

But again I know that it's finicky and that I already battled with this in the past, just not sure if it's exactly this case or if it's still the case.

@Frix-x

Frix-x commented Dec 21, 2023

Copy link
Copy Markdown
Owner

Ok, so now the PR is ready to be merged. I just want to test it thoroughly to make sure it's working before I merge it. So please give me some time to do that (currently batch printing Christmas decorations haha)

@Frix-x Frix-x self-assigned this Dec 21, 2023
@Frix-x Frix-x added next version This thing is already done or is planned in the next version in preparation tracking This issue is tracked and work will be done labels Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

next version This thing is already done or is planned in the next version in preparation tracking This issue is tracked and work will be done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants