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.
Your doors need to exist in 3 - letâs call them âstatesâ:
Cabinet Closed
Door Open, but not retracted
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>)
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)
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)
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?