Large Range Slider?

Hi, has anyone try to create a Large Number Slider?, i been developing some graph combinatorial optimization definitions, but when I get to K8 Graph or bigger, the Grasshopper slider runs out of numbers.
So Im not able to access all subgraph from Kn graphs. You can “solve” the problem by doing a remapping with python or… but the optimization loses resolution.

I suppose thats a matter of the size of the Types in C#?, Thanks

C#, but yeah, sort of. Sliders use the decimal type which supports pretty big numbers with pretty high accuracy. Decimal is a good one to use for UI numbers. However by the time the value leaves the slider it is converted into a double-precision-floating-point type. Doubles have an enormous range, but their accuracy for big numbers is bad and one should avoid using them in calculations lest the errors add up to a significant amount.

I’ve picked limits on the slider that hopefully keep people out of trouble 99% of the time, but it does mean the limits are pretty tight.

If you need to deal with really big integers, then you cannot use any standard Grasshopper logic because all integral maths uses a 32-bit type. This type has an upper bound of 2,\!147,\!483,\!647 (i.e. ~2 billion) It cannot deal with values bigger than those.

If you need to go beyond this range, you’ll have to switch to textual numbers, and convert them into the BigInteger type within custom/script components.

Hi, do you know where I can find the source code of the Normal Slider? Thanks

Grasshopper is not open source, the code is not posted anywhere online.

1 Like

Yes, I understand, I have seen some plugins for grasshopper like genoform, that have very similar sliders to the grasshopper ones. I know there are grasshopper templates in visual studio, for creating components, but I don’t know if sliders works in the same way??.

It is possible that people disassembled the Grasshopper.dll assembly to have a peek at the source. This is forbidden by the licence agreement without express permission by Robert McNeel & Associates, but I’ll be happy to give it for the purpose of developing a GH plugin.

In order to create any ‘special’ object, typically you start by creating a class which derives from GH_Param<T> and override the attributes. Almost all the hard code is in the attributes (display, special mouse handling).

1 Like