Show/Hide nested Component by typing name

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.

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?

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)
Hidden =if(pos<=len(Str),0,1)
or combining

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

1 Like

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

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.


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
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 (32.3 KB)

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.


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
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 (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 (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

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 (47.0 KB)


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