How to limit input values

Is there a way to limit the values of an input?
For example allow the insertion of 3 numbers (1,2 and 3) or a percentage value between 0 and 100. Thank you
input values.dyn (8.1 KB)

Playing with the settings on an integer slider will solve both your problems.

I think you can get this just by slider settingsHj

Thanks for your answers. I tried to set the limits on the node of the slider (min value and max value), but if you enter the value manually, ie without the slider, these limits are not valid!

One thought: Set it up with the datashapes package.

Do you mean setting limits on the allowable input? Ex: Values must be between 1 and 10, therefore 0 and 11 would not be valid inputs?


Yes, right.
The proposed solution is similar to mine, but more compact! I really meant to limit the insertable values, as happens on an Integer Slider node, where inserting 2,3 returns 0.

Thanks for your suggestions.
But is not there a way to limit the input without installing other packages?

You could use python in conjunction with nick’s graph to trigger a pop up and maintain a functional result. How is the graph being run?

Change to output values from INVALID to your minimum limit and maximum limit. That way, if your input is greater than 3 the output is still 3, and if the input is less than -1 the output is still -1 (using my example.)

1 Like

The graph is executed by Revit, starting Dynamo as a plug-in.

I had an idea. But help me! By creating the custom node, I can define the quality of the input (integer, double, boolean …) but can I also define a range of values?

Only in the same ways as we’ve shown. You can’t stop Dynamo from taking an input value. An input will accept any value, it just might throw an error if it doesn’t know how to handle it. You can define a range for any input, but you’re really defining what happens to a value outside that range.

All of the options mentioned above do what you’re asking. If you’re looking for something else you’ll need to be more specific in what you’re expecting as an output.

Have you tried the datashapes method I indicated above?

Sorry! Actually you already gave me two valid solutions. I tried them and they work. My last question was just a curiosity.

If a comment solved your problem, mark it as solved please.