# Show/Hide nested Component by typing name

**URL:** <https://forums.sketchup.com/t/show-hide-nested-component-by-typing-name/185072>\
**Category:** Dynamic Components\
**Created:** [December 28, 2021, 9:27am UTC](https://forums.sketchup.com/t/show-hide-nested-component-by-typing-name/185072 "2021-12-28T09:27:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![david\_hashimoto](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@david\_hashimoto](https://forums.sketchup.com/u/david_hashimoto)\
**Post date:** [December 28, 2021, 9:27am UTC](https://forums.sketchup.com/t/show-hide-nested-component-by-typing-name/185072/1 "2021-12-28T09:27:53Z")

</div>

Hi all. I would like to get some help on creating a specific function for a Dynamic Component. The dynamic component which is a steel frame, contains nested components that are bolts in various locations. I am trying to set-up an attribute so that when multiple locations are typed into the options text box e.g. top 1, top 4, middle 5, then those three bolts only are shown.

Any advice on this would be appreciated.

---

<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:** [December 28, 2021, 2:48pm UTC](https://forums.sketchup.com/t/show-hide-nested-component-by-typing-name/185072/3 "2021-12-28T14:48:14Z")

</div>

Can you explain the options you want to be able to select a little more fully?

And upload a copy of the DC as you have it so far?

Does (for example) “top 4” mean “four bolts in the top of the frame”? Or “bolt no. 4 in the top frame”?

Or something else?

---

<div class="post-metadata">

**Author:** ![pcmoor](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/pcmoor/32/3427_2.png) [@pcmoor](https://forums.sketchup.com/u/pcmoor)\
**Post date:** [December 28, 2021, 9:37pm UTC](https://forums.sketchup.com/t/show-hide-nested-component-by-typing-name/185072/4 "2021-12-28T21:37:33Z")

</div>

For a given string you can find the element to trigger the action, however you need to add that element to the end of the string to search to avoid the error than make the hidden attribute a condition of the result and length of the original string.  
So for  
Str = “T1, T2, B4, M1”  
(I choose some easy to type symbols)  
each bolt would look for its corresponding code (say for “bottom 4”,“B4”)  
pos = find(“B4”,Str & “B4”,1)  
Then  
Hidden =if(pos\<=len(Str),0,1)  
or combining

Hidden =if(find(“B4”,Str & “B4”,1)\<=len(Str),0,1)

---

<div class="post-metadata">

**Author:** ![david\_hashimoto](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@david\_hashimoto](https://forums.sketchup.com/u/david_hashimoto)\
**Post date:** [December 28, 2021, 11:05pm UTC](https://forums.sketchup.com/t/show-hide-nested-component-by-typing-name/185072/5 "2021-12-28T23:05:16Z")

</div>

[example.skp](https://forums.sketchup.com/uploads/short-url/mhIkrHACMBRTNpD3doGTbtsFjcF.skp) (342.3 KB)  
Thanks for the replies. I have uploaded a file to hopefully make my intentions clearer.  
The uploeded file is exactly the same principle, In the uploaded file I would like component options that user can type in colours, for example “red, orange”. and only those two bolts are shown.

---

<div class="post-metadata">

**Author:** ![david\_hashimoto](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@david\_hashimoto](https://forums.sketchup.com/u/david_hashimoto)\
**Post date:** [December 29, 2021, 12:15am UTC](https://forums.sketchup.com/t/show-hide-nested-component-by-typing-name/185072/6 "2021-12-29T00:15:12Z")

</div>

I am a real newb at coding and nowhere near your level. I tried to paste these codes into the hidden behaiviour attribute of the nested components, but it did’nt work. If you would’nt mind looking at the file I uploaded in the later comment and coding that as a base sample that I could modify.

Thanyou.

---

<div class="post-metadata">

**Author:** ![pcmoor](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/pcmoor/32/3427_2.png) [@pcmoor](https://forums.sketchup.com/u/pcmoor)\
**Post date:** [December 29, 2021, 1:57am UTC](https://forums.sketchup.com/t/show-hide-nested-component-by-typing-name/185072/7 "2021-12-29T01:57:03Z")

</div>

Actually can not lump the two together, so need the extra attribute, the formula is trying to evaluate the text  
so use them separately

pos = find(“B4”,Str & “B4”,1)  
will return a number  
then  
Hidden =if(pos\<=len(Str),0,1)  
should work

I made an example, initially using instance names on a common component, then I used the name attribute to give each instance a value the same as its namesake, the only problem with using the “name” attribute, it over-rules and stops the instance and its DC option headers from being synchronized.

[BOLTS ON PLATE.skp](https://forums.sketchup.com/uploads/short-url/alcQW9vdOg1zGKvL0D0OMuYxNEA.skp) (32.3 KB)

---

<div class="post-metadata">

**Author:** ![david\_hashimoto](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@david\_hashimoto](https://forums.sketchup.com/u/david_hashimoto)\
**Post date:** [December 30, 2021, 3:59am UTC](https://forums.sketchup.com/t/show-hide-nested-component-by-typing-name/185072/8 "2021-12-30T03:59:20Z")

</div>

I appreciate your expertise, but I’m really struggling with this. I would have thought trimble would make it simpler for people without coding experience.  
So to confirm the details, in the bolt attribute I should create a custom attribute “POS” then type the command “= find(“B4”,Str & “B4”,1)”. Then also in th bolt attribute I should assign the hidden attribute and type in the command box “=if(pos\<=len(Str),0,1)”

Am I understanding this correctly, because I have tried various ways based on your coding but am still at a loss.

Thankyou.

---

<div class="post-metadata">

**Author:** ![pcmoor](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/pcmoor/32/3427_2.png) [@pcmoor](https://forums.sketchup.com/u/pcmoor)\
**Post date:** [December 30, 2021, 10:19am UTC](https://forums.sketchup.com/t/show-hide-nested-component-by-typing-name/185072/9 "2021-12-30T10:19:58Z")

</div>

> [@david\_hashimoto](#):
>
> would have thought trimble would make it simpler for people without coding experience.

they are working on it, its called live components

Lets step back a bit

Hidden is an attribute that is a boolean. it has two states, either true or false. Now any number greater than 0 is deem as true, any number = 0 or below is deem to be false. So write false into the Hidden attribute value, or 0 or - 12.569, the object will be seen, whereas write 0.0001, true, 1, 500, the object will be hidden.

So just to make less typing, I use 1 and O for true and false,

Try some simple ideas first:  
Using the interact (finger tool)

Ideally each bolt should be an instance of the same definition, so if I select hidden and onclick in one it should open in the others, so try putting  
set(“Hidden”,0,1)  
in the onclick value and that should propagate too  
however your example has four separate components  
So had to add the formula to each one. Then I added an onclick to the box to make them all visible, otherwise need to turn on view / hidden objects.  
[example (8) onclick.skp](https://forums.sketchup.com/uploads/short-url/61vTpeeWK1dChnt1gy3ePbcxxik.skp) (102.0 KB)

Now how to choose from dropdowns  
simply fill the value section with the options: 0, or 1 then pass that to the bolt concerned

[example (8) dropdowns.skp](https://forums.sketchup.com/uploads/short-url/8OaDg5j7X0uTnbn1FHier4Dn79z.skp) (73.2 KB)

now you want to choose the bolts using one textbox, that means that one has to extract the text from the input string. A more difficult task.  
so use the FIND function

FIND(findText,text,position)  
this returns an integer at findText’s position if findText exists in text, otherwise it returns -1, an error. Errors can stop a DC from working! so to overcome this one can add the text you wish to find at the end of the search string. Then one compares this to the length of the original string to see if it is within it.  
There is no error trapping in this function, there is likely to be no fix, as they want live components, that is, they want to build another wheel rather than fix this one, so you need to workaround. You will find this often, but myself and others have traveled this road and are willing to help

Consider the if statement, it has a condition, when met , returns the next comma delimited value, otherwise the last,  
the condition is the findText position within the length of the original string?

if(position\_of\_ findText\<=LEN(original\_text),0,1)

which can be placed in HIDDEN

[example (8) ONE TEXTBOX.skp](https://forums.sketchup.com/uploads/short-url/sZXboncuWuHsAIHrdViivRnDqkE.skp) (47.0 KB)

---

<div class="post-metadata">

**Author:** ![david\_hashimoto](https://avatars.discourse-cdn.com/v4/letter/d/bc8723/32.png) [@david\_hashimoto](https://forums.sketchup.com/u/david_hashimoto)\
**Post date:** [December 30, 2021, 12:10pm UTC](https://forums.sketchup.com/t/show-hide-nested-component-by-typing-name/185072/10 "2021-12-30T12:10:58Z")

</div>

Wow, That is exactly what I wanted. I have been agonising over it for many days. Thank you very much. really appreciate it !!
