Validate input range for Dynamic Component?

I’ve been looking with Google’s help for any example of a Dynamic Component checking input values for ‘reasonableness’. I haven’t found any, using variations of ‘sketchup dynamic component validate input’ as the search term (without the quotes).

Is this possible? I haven’t found any examples in the tutorials in the 3D Warehouse, or in any of several DCs I’ve downloaded. I know I could use a fixed drop down list, but the range of possible values is rather large, and not really confined to particular values - I just want the input to be between MinValue and MaxValue.

I feel it ought to be possible using some combination of a Custom attribute for the original input, the IF function, and the CURRENT function (something like 'IF the CURRENT value of TextInputBox is LESS THAN MinValue, SET LenX = MinValue).

But in my early efforts, I get Circular Reference or just plain syntax errors.

Am I on roughly the right lines? Is it possible at all? If so, why can’t I find any examples?

Hoping for help on this. Thanks in advance for any suggestions.


Note I have NOT checked the above!

There are a LOT of Dynamic Component functions that can be used for input checkingL

Combine them with IF (and other logical functions)
Blend them with any math function that returns a TRUE/FALSE value

Lot’s of possibilities!

Have you checked out the Function Reference?

If this doesn’t help, please let us know the specific test you’re trying to apply and let us brainstorm!

Tried that (for LenZ rather than LenX), and get error ‘lenz [attribute 0.0 not found]’

What I put in the LenZ attribute:

What I get out:
=largest(current(“lenz” [attribute 0.0 not found]),7.0)

with the bold text shown in red in SU.

Can’t see why this doesn’t work.

I also want to limit the maximum value, but that’s less important.

PS. An when I try =LARGEST(LenZ,7.0) I get not surprisingly Circular Reference.

1 Like

AHA! I have something that DOES work to limit the minimum value.

Add Custom attribute Height, set visible as Text box, displaying Inches.

Add to LenZ attribute = LARGEST(Height,7.0).

I got an error (attribute “height” not found) at first, but when I went ahead anyway, it started to work.

Now to see how to limit Maximum value as well, if possible.

As before, add Custom Height attribute.

Then for LenZ attribute put in:
=IF(Height <7.0,7.0, IF(Height>96.0,96.0,Height))

1 Like

A follow up question: is it possible to reorder the Component Options fields? I’d like to add a read-only display of the height actually used, to show how the validation rule has used min or max values, but at the moment the LenZ field displays first.

Again, I’m away from my computer, so this is my best recollection - NOT verified!

Component Options display alphabetically - by their underlying attribute name - NOT their displayed name. So you can (at times painstakingly) rename your attributes so that they will show up alphabetically in Component Options. Then, in the user input options for each attribute, you can set what name you want displayed - which doesn’t have to be alphabetical.

Thank you. That works fine for custom variables, but the built in ones always come first, it seems. However, I can add a Custom variable UsedHeight = LenZ and display that, in order as you say, to show when a Max or min value has been used instead of user’s original input.