Redraw a parent when clicked on a child component

Hello, guys!
Could you help me with a dynamic component please?

I have a dynamic component, which consists of:

  1. Two key switch.
  2. One key switch.
  3. Two small lamps.
  4. One big lamp.

My goal is to link lamps materials to the key switch pressed event. In works perfectly, when components are on the same hierarchy level. But it doesn’t work when a component has its own hierarchy.

For instance:

  1. When a one key switch is clicked, then the big lamp is switched on / switched off. The big lamp material is linked with a switch button via parent component parameter.

LampBig → Material → =IF(parent!isButtonPressed=1,“LightsOn”,“LightsOff”)
OneKeySwitch → onClick → SET(parent!isButtonPressed,0,1);

  1. When a two key switch left button is clicked, then the small lamp should be switched on / switched off. But its material is changed only when dynamic component is redrawn.

LampSmall → Material → =IF(parent!isLeftPressed=1,“LightsOn”,“LightsOff”)
Parent (SwitchersLamps) → isLeftPressed → =TwoKeySwitch!isLeftPressed
TwoKeySwitch → isLeftPressed → linked to nested dynamic component

  1. When a two key switch right button is clicked, then the small lamp #2 should be switched on / switched off. But its material is changed only when dynamic component is redrawn. The same as for the left switch button.

LampSmall2 → Material → =IF(TwoKeySwitch!isRightPressed=1,“LightsOn”,“LightsOff”)
TwoKeySwitch → isRightPressed → linked to nested dynamic component

The SketchUp 2022 project file and screenshots are attached.

Would be grateful to get an instruction how to solve a problem with redraw. Or maybe a statement, that my idea will not work.
Thanks in advance!




SwitchersLamp.skp (128.6 KB)

OnClicks should always be on same level. I placed the switch object changes one level down. Not necessary to have a parent for all devices, but if required, do not place functions that require redraw

If the DC function were not an extension, but native code, redraws would not be required.

SwitchersLamp 2.skp (143.9 KB)

1 Like

pcmoor, thanks a lot for your instructions and example!