How can I get a Number Slider object and set a value?

It’s very strange, and frustrating. I have a break in my code, before GH_Document.NewSolution and after the new slider values are set and the current solution is expired.

At that point I can manually ask Grasshopper to recalculate, after which the code runs fine until the next iteration.
However, doing what should be the same thing in code with GH_Document.NewSolution causes the crash …

I solved the problem by changing to:
GH_Document.ScheduleSolution(1);

1 Like

Gentlemen,

Thanks for the helpful discussion.
Is there a way to retreive float values from the number sliders? Since for example 71.80 now is returned as 7180. Thanks,

Jelle

1 Like

Hi Jelle,

It should be no problem to retrieve float values, I do it all the time.
Probably the issue has something to do with how you parse/cast the data.

Cheers,
Thomas

1 Like

Hi Thomas,

I’m trying to do something similar (optimize a set of number sliders to minimize a function defined in grasshopper) and I happened upon your discussion here. Did you ever figure this out? I’m a bit new to python but know Grasshopper fairly well, and I’d like to use python within the GH environment.

Thank you!
Moh

1 Like

Hi @ismail,

I know how to do this only in C#, and, frankly, it is a bit of an advanced topic.
Nevertheless, the information in this thread should be what you need.

Cheers,
Thomas

1 Like

I have a similar problem and am curious if anyone was able to get this working in the most basic manner for Python 3??

This is the post I just made Python 3 controlling a Number Slider

Thanks in advance,

Andres