# Validate input range for Dynamic Component?

**URL:** <https://forums.sketchup.com/t/validate-input-range-for-dynamic-component/22524>\
**Category:** Dynamic Components\
**Created:** [March 24, 2016, 12:58pm UTC](https://forums.sketchup.com/t/validate-input-range-for-dynamic-component/22524 "2016-03-24T12:58:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_mcclenahan](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/john_mcclenahan/32/135377_2.png) [@john\_mcclenahan](https://forums.sketchup.com/u/john_mcclenahan)\
**Post date:** [March 24, 2016, 12:58pm UTC](https://forums.sketchup.com/t/validate-input-range-for-dynamic-component/22524/1 "2016-03-24T12:58:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sjdorst](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/sjdorst/32/13212_2.png) [@sjdorst](https://forums.sketchup.com/u/sjdorst)\
**Post date:** [March 24, 2016, 2:55pm UTC](https://forums.sketchup.com/t/validate-input-range-for-dynamic-component/22524/2 "2016-03-24T14:55:58Z")

</div>

> [@john\_mcclenahan](#):
>
> 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).

`=LARGEST(Current("LenX"),MinValue)`

Note I have NOT checked the above!

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

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](https://help.sketchup.com/en/article/114561)?

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

---

<div class="post-metadata">

**Author:** ![john\_mcclenahan](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/john_mcclenahan/32/135377_2.png) [@john\_mcclenahan](https://forums.sketchup.com/u/john_mcclenahan)\
**Post date:** [March 24, 2016, 3:32pm UTC](https://forums.sketchup.com/t/validate-input-range-for-dynamic-component/22524/3 "2016-03-24T15:32:47Z")

</div>

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

What I put in the LenZ attribute:  
=LARGEST(CURRENT(“LenZ"),7.0)

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

---

<div class="post-metadata">

**Author:** ![john\_mcclenahan](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/john_mcclenahan/32/135377_2.png) [@john\_mcclenahan](https://forums.sketchup.com/u/john_mcclenahan)\
**Post date:** [March 24, 2016, 3:50pm UTC](https://forums.sketchup.com/t/validate-input-range-for-dynamic-component/22524/4 "2016-03-24T15:50:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![john\_mcclenahan](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/john_mcclenahan/32/135377_2.png) [@john\_mcclenahan](https://forums.sketchup.com/u/john_mcclenahan)\
**Post date:** [March 24, 2016, 3:56pm UTC](https://forums.sketchup.com/t/validate-input-range-for-dynamic-component/22524/5 "2016-03-24T15:56:05Z")

</div>

GOT IT!  
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))

---

<div class="post-metadata">

**Author:** ![john\_mcclenahan](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/john_mcclenahan/32/135377_2.png) [@john\_mcclenahan](https://forums.sketchup.com/u/john_mcclenahan)\
**Post date:** [March 24, 2016, 4:07pm UTC](https://forums.sketchup.com/t/validate-input-range-for-dynamic-component/22524/6 "2016-03-24T16:07:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sjdorst](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/sjdorst/32/13212_2.png) [@sjdorst](https://forums.sketchup.com/u/sjdorst)\
**Post date:** [March 24, 2016, 6:09pm UTC](https://forums.sketchup.com/t/validate-input-range-for-dynamic-component/22524/7 "2016-03-24T18:09:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![john\_mcclenahan](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/john_mcclenahan/32/135377_2.png) [@john\_mcclenahan](https://forums.sketchup.com/u/john_mcclenahan)\
**Post date:** [March 25, 2016, 6:07pm UTC](https://forums.sketchup.com/t/validate-input-range-for-dynamic-component/22524/8 "2016-03-25T18:07:26Z")

</div>

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.
