Passing attribute instructions beyond the child level

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

  1. The Height is passed strait to the main structure from a drop-down list.

  2.  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.  
  3. 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.

  4.  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.
  5. 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.

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

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

Create the same attributes and use Parent! to refer one level up. (eg. :
Adjecent=Parent!Adjecent )

1 Like

Wasn’t aware of that, However, it appears that you could use this to pass down as many levels as you would like by duplicating the index attribute and changing the =CHOOSE to reflect the parent.
Not sure how that would work with the adjacent command.

Thanks, I couldn’t find this documented in the functions and it is much easier for some events.
Thanks,for the heads up.


1 Like

It would be so much easir if SketchUp DC would just provide some method for having global attributes, that can be referenced from any point in a hierarchy without needing to copy them explictly down through many levels with the undocumnted but extremely useful “parent!” attribute. This is often necessary in a complex model, but it’s a real pain to have to copy the same thing dozens of times, to every single level of a hierarchy… Very slow, and very inefficient. People have been asking for “global attributes” for years, but Trimble seems to be either deaf, or unable to figure out how to implement this simple feature…

1 Like