Passing attribute instructions to the child level and Beyond!
Today while working on a dynamic component, “WonderStructure Stage Support”, that needed attribute information to be applied to the second nested level, that would be the grandchild level, I guess.
The component requires the height to be adjusted, “LenZ” from a drop-down list. This required that the legs be organized into two separate sub-components, named “Static Upper” and “lower leg”. It further requires that some “Locator Plates”, located within the upper leg component have their rotation passed through to each of the “Locator Plates” inside the “Static Upper”.
-
The Height is passed strait to the main structure from a drop-down list.
-
The rotation couldn’t be passed strait to the “Locator Plates” because they are inside a sub-component, not in the child level of the, “WonderStructure Stage Support” component.
-
This is done in the “Custom” attribute box, I called it “Adjacent” for adjacent pieces and where they sit in relation to this Component piece; none, Long side, short side, corner, both long sides, both short sides, these return the values 1-6. The options again being chosen from a drop-down list. Following this will be and additional custom attribute, named “Index” and the argument formatted as “=optionIndex(“adjacent”)” this will pass the choice to the receiving attribute using the “=CHOOSE(WonderStructure Stage Support!index,1,2,3,4,5,6)” argument.
-
This choice then needs to be passed down/through to the “Locator Plates” inside the “Static Upper” component. The OPTIONINDEX Function is used for this, the attribute name is "Index" and the argument formatted as “=CHOOSE(WonderStructure Stage Support!index,1,2,3,4,5,6)”. It returns the value of the “Adjacent” choice.
-
The component receives this information, in this case the “Static Upper” component. It would normally take the value into the attribute like “LenZ” or another attribute, in this case I used “Index”, which allows us to pass the choice through to the “Locator Plates” by using back to back instances of the OPTIONINDEX Function.
The attribute must be named “Index”, not index1 or indexA or 2index. This limits you to only a single usage of this per component. The format for the “Index” argument is “=CHOOSE(WonderStructure Stage Support!index,1,2,3,4,5,6)”. The name of the top level component followed by “… !index,x1,x2,x3,x4,x5,x6, … x46, …)”, x1-46 being the values, one of which will be passed to the attribute. -
However, I have determined that for this second nested component I could pass the choice by a second use of the custom attribute “index” and use the “=CHOOSE(WonderStructure Stage Support!index,1,2,3,4,5,6)”argument and pull the attribute choice information down to this attribute. We don’t apply the choice here; we apply it by a second use of the OPTIONINDEX Function this time from within the “Static Upper” component.
-
Now the nested components, “Locator Plate…”, that are part of the “Static Upper” component can call the “index” information, in this case the “RotZ” attribute with the argument “=CHOOSE(Static Upper!index,0,90,0,90,90,270)” with the numbers being the degree of rotation needed for that plate.
Shown in short:
WonderStructure Stage Support (Main component)
--------- Custom attribute
-------------------- Adjacent
------------------------------------ List option ---------- Value
------------------------------------ none--------------------1
------------------------------------ Long side--------------2
------------------------------------ short side--------------3
------------------------------------ corner------------------4
------------------------------------ both long sides----- 5
------------------------------------ both short sides-----6
------------------ Index =optionIndex(“adjacent”) (Returns selected value from list)
--------- Static Upper (sub-component)
------------------ Custom attribute
---------------------------- Index =CHOOSE(WonderStructure Stage Support!index,1,2,3,4,5,6)
------------------ Locator Plate… (sub-component within Static Upper )
---------------------------- RotZ =CHOOSE(Static Upper!index,0,90,0,90,90,270)
------------------------------------- (The value returned from Index 1-6 will be the number in sequence
------------------------------------- returned to RotZ, 1 is 0 degrees and 6 would be 270 degrees)
The component is attached for your review.
It hasn’t been polished up for finish.
Wonder structure workspace.skp (3.8 MB)