Hiding/Showing Components within a Dynamic Component

I do design and config work for a company that sells railings. We have some preset designs for posts, and I’m trying to make a more efficient workflow for me to model them. Basically, what I want to do is create a post with the components for a top middle bottom rail, and then be able to select a dynamic option to hide the other components that I won’t be using if it’s a single or double rail. As of right now, I manually do that, which is fine, but time consuming when I have a number of posts to configure.

Is there a way to create an attribute that could show/hide specific components when an option is selected?

Here’s the link to the .skp file.

Here you can see the attribute of an option like that,(Dropbox - File Deleted) my English is not very good so it’s easier for me to just show an example, there may be better ways to do it but this is how I do it, just trying to help out

It’s built in to Dynamic Components.

One of the built in attributes which you can use is “Hidden”. Set it to TRUE and the component is hidden, FALSE and it appears again.

Open the Dynamic Component Attributes window. Click the + to add new attributes. Scroll down to find “Hidden”.

In your specific case, you might also want to create some custom attributes in your outermost component:

  • HideTopRail
  • HideMiddleRail
  • HideBottomRail

Then, in each individual rail component, use parent! to set the value of the rail’s Hidden attribute.

Note that your rails will only be completely hidden if you uncheck “View Hidden Geometry” in the View menu.

1 Like

That makes sense. Can you give me an example of a logic statement using “parent!”?

EDIT: Sorry, I know how to use “parent!”

What I am really struggling with is how to reference a value from a drop down list in the custom attribute so that when I select “Top Rail” in Component Options, the proper components hide themselves.

The simplest technique (I believe) is to allot a value to each option and use choose with reference to the dropdown as per example attached.
hidden_example1.skp (34.1 KB)

you can reference the dropdown list using OPTIONINDEX(“attributeName”) in lieu of values so in the example in the parent make an attribute =OPTIONINDEX(“type”) then reference that
hidden_example2.skp (34.4 KB)

1 Like

So I rebuilt the end post with some newer models, and I used IF(OR functions to reference the list.

Do you think the lag in the model updating would improve if I used the choose function instead?

Also, for some reason, I couldn’t get the angled components to reference the top level component to rotate, so I had to nest parent! expressions all the way down to transfer the value. Is there a reason why the component name wouldn’t trigger the behavior?

The use of “parent!” is a shorthand that lets you not worry if you change the name of the referenced component - your formula will still work. Unfortunately, “parent!” can’t be chained to go up more than one level. Your workaround of custom variables at each level that use “parent” is a PITA, but a useful one. The other way to do it is to simply use "<component_name>!<attribute_name> only where you need it. Unlike “parent!”, you can “reach” any component that either the top level component or nested subcomponents without the intervening pass through attributes. But be prepared for debugging problems if you change any component names!

OK. First, in the top level component, set it up something like this:


See the letters which I’ve prepended to the name? They’re important! More on that later …
Now, for each of these components, click it’s edit icon (on the right) bringing up the screen to define user visibility/edit/choice:

Two things to note here:

  1. TRUE and FALSE are represented internally as <non-zero> and 0, so the values I’ve defined in the pulldown represent what we want the “hidden” attribute of the target component to be, so to see a rail, the value 0 (NOT hidden) is needed.
  2. I’ve changed the Display Label to hide the alphabetic prefix from what the user sees.
    Once you to the above for each of your custom variables, your “Component Options” window should look like:

    Now back to those alphabetic prefixes. I used them because SketchUp displays attributes in the Options window alphabetically by name, but I want them to appear in the order of: Top, Middle, Bottom. Without the prefix, they’d appear as: Bottom, Middle Top. And I use letters because SketchUp doesn’t allow attribute names to begin with a number.

The other way to do it is to simply use "<component_name>!<attribute_name> only where you need it.

So I tried this:

=< ADAEndPost >!Angle

The entire expression stayed red, which I believe means it’s not working. Do I need to bracket both names?

The “!” separates the <component_name> from the <attribute_name>. If you don’t use <component_name> then you’re referencing an attribute in the same component as the formula - and you don’t need the “!”.

Sorry, the html made the component name disappear, I edited it. In the formula, I didn’t have the spaces in there.

Oops! My bad (possibly)!

When I wrote <component_name>!<attribute_name>,
given the name of my component is “DemoComponent” and the name of my attribute is “DemoAttribute”, in use, I’d write “DemoComponent!DemoAttribute” in the formula. The “greater than” and “less than” signs shouldn’t appear in the formula, nor, for completeness, should the quotation marks!

Of course, that makes sense! That’s probably the one combination I didn’t try.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.