How to limit input values


#1

Hi!
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)


#2

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


#3

I think you can get this just by slider settings


#4

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!


#5

One thought: Set it up with the datashapes package.


#6

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?
image


#7


#8

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.


#9

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


#10

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?


#11

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.)


#12

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


#13

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?


#14

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.


#15

Have you tried the datashapes method I indicated above?


#16

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


#17

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