Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Expressions & Variables in numeric input fields #3175

Closed
jhlchu opened this issue Sep 4, 2022 · 2 comments
Closed

[FR] Expressions & Variables in numeric input fields #3175

jhlchu opened this issue Sep 4, 2022 · 2 comments
Labels
fix is live in the last release Please download /build the last release and try to reproduce. problem

Comments

@jhlchu
Copy link

jhlchu commented Sep 4, 2022

Is your feature request related to a problem? Please describe.
I use the same Print Setting profile for printing small and large objects, but sometimes the speed (using autospeed) blitzes some of the layers on small objects, requiring some manual adjustment to the profile. Want to be able to selectively override autospeed or other values with expressions like min or max and use printer variables in them.

Describe the solution you'd like
Being able to use basic expressions and printer variables in numeric input fields.

Describe how it would work

  • "Print Settings" > Speed > External: min(15, InternalPerimeter.speed)
  • "Print Settings" > Width > Perimeter: max(0.4, LayerHeight * 0.8).

Describe alternatives you've considered
Making manual adjustments then slicing, to see.

@supermerill supermerill added the wontfix This will not be worked on label Sep 6, 2022
@supermerill
Copy link
Owner

supermerill commented Sep 6, 2022

Too problematic with cyclic references.

@supermerill supermerill added fixed for the next version That means that you should be able to test it in the latest nightly build and removed wontfix This will not be worked on labels Sep 6, 2022
@supermerill
Copy link
Owner

supermerill commented Sep 6, 2022

That motivated me a bit to test & debug the scripted widget.
starting from next nightly, add that in your print.as:

float s_ext_peri_speed_get(bool &out isper)
{
	isper = is_percent("external_perimeter_speed");
	float fl = get_float("external_perimeter_speed");
	if(isper || fl < 15) {
		ask_for_refresh();
		return 15;
	}
	return fl;
}

void s_ext_peri_speed_set(float val, bool isper)
{
	if(!isper){
		if( 15 > val) {
			val =15;
		}
		set_float("external_perimeter_speed", val);
	}
}

float s_peri_extr_width_get()
{
	float fl = get_computed_float("perimeter_extrusion_width");
	float layer_height = get_float("layer_height");
	float val = fl;
	if(layer_height * 0.8 < val) {
		val = layer_height * 0.8;
	}
	if( 0.4 > val) {
		val = 0.4;
	}
	if(val != fl){
		ask_for_refresh();
		return val;
	}
	return fl;
}

void s_peri_extr_width_set(float val)
{
	float layer_height = get_float("layer_height");
	if(layer_height * 0.8 < val) {
		val = layer_height * 0.8;
	}
	if( 0.4 > val) {
		val = 0.4;
	}
	set_float("perimeter_extrusion_width", val);
}

and in your print.ui, replace setting:width$4:external_perimeter_speed by setting:script:float_or_percent:depends$external_perimeter_speed:tags$Simple$Advanced$Expert$SuSi:label$My external speed:tooltip$issue 3175:s_ext_peri_speed
and

line:perimeter
	setting:sidetext_width$10:label$width:perimeter_extrusion_width
	setting:sidetext_width$10:label_width$15:label$spacing:perimeter_extrusion_spacing
end_line

by setting:script:float:depends$perimeter_extrusion_width:tags$Simple$Advanced$Expert$SuSi:label$My perimeter width:tooltip$issue 3175:s_peri_extr_width

DOCUMENTATION

supermerill added a commit that referenced this issue Sep 6, 2022
fix refresh for float/&percent
fixed ask_for_refresh() for non-bool
#3175
supermerill added a commit that referenced this issue Sep 12, 2022
fix refresh for float/&percent
fixed ask_for_refresh() for non-bool
#3175
supermerill added a commit that referenced this issue Sep 16, 2022
fix refresh for float/&percent
fixed ask_for_refresh() for non-bool
#3175
@supermerill supermerill added fix is live in the last release Please download /build the last release and try to reproduce. and removed fixed for the next version That means that you should be able to test it in the latest nightly build labels Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix is live in the last release Please download /build the last release and try to reproduce. problem
Projects
None yet
Development

No branches or pull requests

2 participants