Dynamic Nested Components

I have modeled a bank of drawers and am trying to move a drawer box and drawer face 24" in Y direction onClick and 24" back to its original location with the second click. I have some experience with Dynamic Components and usually don’t have the issues I was experiencing today.

The components are nested, the cabinet box, drawer boxes, and drawer faces are all in one component. Double clicking enters into it, from there I can isolate the cabinet box, or isolate the drawer box and drawer face. Double clicking again I can isolate the drawer face from the drawer box.

I am trying to have the component containing the drawer box and nested drawer face move. I have played around with moving the axes to different locations, when I do, it shows my Y position as 0 which is nice and what I would want.

I write into the component attributes for the drawer box and nested drawer face: onClick(Animate"Y",24,0)

You’d think the drawer box and drawer face would move when clicked the 24" in Y and with second click go back to its orignal position. However, some weird stuff happens.

First off, when I exit the nested components and go back to looking at the whole model, my Y position value changes, which I don’t understand. Additionally, when I do the onClick function, the drawer box and face move together, but never 24" out and 24" back in. It jumps the opposite direction I want it to go, and then on the next click, even further backward, and never returns to its original location.

I have a feeling there is something I am missing about where to place the axes for the component, or maybe where the model is sitting in Sketchup space overall. An answer here would be very much appreciated. Thank you!

It would help if you share the model so we can see exactly how you have it set up. It should be pretty straight forward, though. I expect you need to make the the 24 negative, though. I just whipped up this example. The none of the other components including the top level have any attributes assigned in my model.

drawer

1 Like

Check it out. Funny enough it works fine now. Its the top drawer behind the bench. I want to animate all of them this morning to show off to the client.

Queen Built In.skp (177.3 KB)

To recreate the issue I found try opening the cabinet component and try onClick on the top drawer and drawer face.

Once I close out of the component and am looking at the entire model again it performs as it should.

Which one?

Rightmost

Queen Built In.skp (179.5 KB)

Now all 10 drawers open and close how I would like. Since you have my model in front of you, could you answer why both sides move for the drawers behind the bench, and down below they each open and close on their own. I definitely copied components and mirrored things using scale -1 but they should each be unique. There was some evidence of this when I made the bottom drawers animate because I only had to code for the right two and the middle two (middle is slightly smaller) and the left two had the dynamic attributes automatically but doesn’t open at the same time as the mirrored one.

The reason it works when you don’t have the components open for editing is the position Y reference is coming from the drawer box itself. I made an extra level of nesting so so there’s a fixed reference for the drawer. I also made a component for the drawer box itself.

drawer

So the nesting looks like this in Outliner.

1 Like

Except they aren’t using. You didn’t do that step. Select one of them and look in Entity Info. It shows there’s two of them.

1 Like

Thank you Dave, being able to go back and forth like this is unbelievably helpful. Learning this way is very effective, I get a little better every time. Have a great day!

1 Like