Animating pocket doors with the Interact tool

Hi there,

Please see the attached file showing a cabinet with two pocket doors.

DC - POCKET DOORS.skp (641.2 KB)

I am looking to animate these doors with the interact tool. So far I have animated them opening through 90 degrees. What I would like to do is, on the next click, have the doors move back into the pocket, a further click to return them to their open position, and finally one last click to close them, returning to their original position.

So a total of four movements with four clicks: open, into pocket, out of pocket, close.

Is this possible?

Many thanks for your time!

It’s absolutely possible!

The general approach is this:

Your doors need to exist in 3 - let’s call them “states”:

  1. Cabinet Closed
  2. Door Open, but not retracted
  3. Door Open and retracted.

Create a custom attribute: Door_State
Door_State will hold one of the above 3 values. But you won’t change the door state directly! Instead, your “OnClick” action will be

Animate(“Door_State”,1,2,3,2)

When you use the interact tool, each click will change the state:
First click changes state from 1 to 2
Second click changes state from 2 to 3
Third click changes state from 3 to 2
Fourth click changes state from 2 to 1

You’ll need to reformulate your door rotation and position attributes to be one that makes a decision based on the value of “Door_State”.

For states 1 and 2, the only differences will be in the rotation of your door. State 3 gets the same rotation as state 2. Since only State 1 has a rotation of zero, set your rotation attribute to something like “=IF(“Door_State”=1,0,90)”

For states 2 and 3, the only differences will be in the POSITION of your door - and state 1 gets the same position as state 2. Since only State 3 has a position equivalent to “retracted”, set your position attribute to something like:

=IF(“Door_State”=3, <y position when retracted>, <y position otherwise>)

I leave the implementation to you.

1 Like

or in one action…
cabinet door.skp (655.6 KB)

2 Likes

Not what the OP asked for. But neat nonetheless!

1 Like

This looks great and is exactly what I am trying to do, but I can’t work out what is going on in the code I have downloaded from this SketchUp model. I can see you have added a custom attribute but can’t see the settings on this. Any chance of an explanation or screen-shot?

Rather than using multiple onClick commands or stringing animate functions (which work concurrently) you set up one attribute that fits the scope of your operations. This attribute which changes in small intervals with onClick can be tapped into like a time line to run many movements or changes.
I have used your file from the other post, the right door uses animateslow, which is probably too fast, whereas the left uses animatecustom (better with more control) with time as 1.5 (this can be varied in proportion to the complexity of the model) .
Bar Unit.skp (74.1 KB)

That animatecustom version works a treat and looks fricking awesome, but I am still a little confused as to how it exactly works and what is doing what. In the Custom attribute with ‘step’ set as 0, what does this mean and is that all that needs to go there, or is there some sort of more complex function setup in the background? (I am evidently quite new to SketchUp and animations). Also what is the ‘lenx,0’ bit in there? ANIMATEcustom(“step”,1.5,0,0,-90-lenx,0)

1 Like

The animatecustom function consist of 6 or more parameters.
The first is the attribute which to be animated, the second is the timeframe in seconds of the animation.
The third and fourth are controlling the speed within the timeframe, easein the speed of the begin, easeout the speed at the end. These are calculated in percentage (value 0-100)
The last parameters are just an array of values that the attribute jumps to after a click, if there are only two, it’s basically a switch.

For true animation, you need to alter the easein and easeout, because when you open the door, the rotation should be quicker than the sliding backwards, but when you want to close the cabinet, you probably want to draw the door first, before rotating it.

This can also be done by adding some custom attributes as you did with the second parameter (timeframe), switching ease in and out based on the current state of the door (open or closed)

See the other thread:

(It’s not a good idea to spread your questions over different topics)

1 Like

Just a newbee here - learning SU. So all the developer comments about creating dynamic states are future music for me. But why is the right pocket in the model cabinet door.skp different from the left pocket? Is this functional, or is it simply due to an incomplete model?

user preference for the two different methods of onclick, shows difference between animatecustom, animateslow

the axis of rotation is different for left and right swing, so different position and sign of rotation

it is possible to create a mirror copy, but easier to manage two separate entities