Animating child group by clicking the parent (onClick) produces error

I’m currently learning how to work with dynamic components, and this issue has been keeping me busy for 3 days now. The problem isn’t too dificult imho, so I’m probably just missing something obvious.

I’m trying to animate a desk that’s adjustable in height (a rough recreation of Ikea’s idasen desk). When the desk is clicked, the top part and the mid part should move a different distance (while the bottom part stays in place).

I grouped two groups, “top” and “mid”, together in a group called “movable components”.
However, when I use the code “ANIMATE(“Top!Z”,0,27,-32);” in an onclick attribute for the group “movable components” (in order to get the “top” group to move when “movable components” is clicked), I get the message “ERROR: Invalid entity to animate: (Top!Z)”

Adjusting the code to “ANIMATE(“Z”,0,27,-32);” produces no error, but obviously doesn’t move the correct group. Of course, I could use that code on the “top” group, but then I would be able to make the “mid” group move on the same click.

I’ve tried turning the groups into components, typing in the code, copy-pasting the code, inputting the code by clicking on the relevant attribute, restarting sketchup, … No dice so far.

Anyone know what I’m doing wrong?

IDASEN.skp (329.9 KB)

Moving components, onClick: ANIMATE(“Z”,0,27,-32);

Thanks for replying! However, that’s not the desired behaviour.

I need the top and mid parts to move a different distance (see how on the lowest setting the legs protrude through the bottom?)

you use a third party attribute to pass the data, there are workarounds in using DCs
as you are using sub groups rather than components, their lengths have to be set

I added a range using Smallest, Largest to govern the extension,
IDASEN.skp (325.2 KB)

1 Like

That works, thank you!

(Seems like I still have a lot to learn, though - gonna have to tinker with things a bit to fully understand what you did there :wink: )