Dependent positioning of stacked components

The Task

  1. I want to stack different modules of a product,
  2. replace them in position if needed by another,
  3. change their version or orientation,

1 to 3 i can create with “onClick” but what i dont know is, how to programm the relationship of the Zposition of each module to a previous added module with different height.
If i replace Module 4, which is 180 units high with, lets say module 2 which is only 60 units high, the on-top stacked modul 1 should change its position in Z downwards, to sit properly on the adjacent module.
So i have to work with if functions in the Attribute components? How this can to be done?
And :slight_smile: has someone a link to a good introduction into programming within SketchUp for real beginners (beside the documentation) :wink:

This would be much easier with a sketch from you…

You are right, i`m sorry, here is a front view

4 different modules, 1, 2, 3 with one size, nr. 4 is 180 instead of 60 mm high…

So when i remove Nr. 4, the top copy of moduel 1 should slide down on the top of Nr. 3 :slight_smile:

And vice versa…


I never done something like that.

I’m imagining that the positioning principle is fairly simple as you position Comp1 in Z=0 then, position Comp2 at Z=0+Comp1!LenZ and so on for all 4 components.

The thing I haven’t done yet is replacing a component for another. I think it requires layers, having all components nested inside the same DC, and show the correct layer with some user action. User input table would probably be #1 choice but Onclick probably would allow you to cycle through options.

Someone more experienced might give you precise ways of doing it, I hope I unveiled some clues…