# Simple Swing Door onclick

**URL:** <https://forums.sketchup.com/t/simple-swing-door-onclick/77387>\
**Category:** Pro\
**Tags:** onclick, animate\
**Created:** [September 21, 2018, 3:48am UTC](https://forums.sketchup.com/t/simple-swing-door-onclick/77387 "2018-09-21T03:48:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![james74](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@james74](https://forums.sketchup.com/u/james74)\
**Post date:** [September 21, 2018, 3:48am UTC](https://forums.sketchup.com/t/simple-swing-door-onclick/77387/1 "2018-09-21T03:48:46Z")

</div>

I am trying to animate a door to swing open onclick.

I have drawn the simplest rectangle and pushed it into a 3d shape.

I have made this shape into a component and set its axes to the corner that I wish it to hinge at.

I have then created a dynamic attribute of onclick: animate(RotZ,0,90).

This works well, but the door swings the wrong way.

If I change the onclick to read: animate(RotZ,0,-90), then click the door, it opens the right way, but the second click has not visual affect, but there is now an attribute called -90 who’s value changes each time I click from 0 to -90 and back.

Can anyone offer a suggestion on how I can resolve this?

[Door.skp](https://forums.sketchup.com/uploads/short-url/cmIuPqmqRaX3T10DwZdU4owpYnH.skp) (160.2 KB)

---

<div class="post-metadata">

**Author:** ![pcmoor](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/pcmoor/32/3427_2.png) [@pcmoor](https://forums.sketchup.com/u/pcmoor)\
**Post date:** [September 21, 2018, 5:14am UTC](https://forums.sketchup.com/t/simple-swing-door-onclick/77387/2 "2018-09-21T05:14:57Z")

</div>

you could use animate(“rotz”,0,-90) provided smart quotes is off (mac issue)

---

<div class="post-metadata">

**Author:** ![MikeWayzovski](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/mikewayzovski/32/98346_2.png) [@MikeWayzovski](https://forums.sketchup.com/u/MikeWayzovski)\
**Post date:** [September 21, 2018, 5:39am UTC](https://forums.sketchup.com/t/simple-swing-door-onclick/77387/3 "2018-09-21T05:39:51Z")

</div>

Yes, most times it is beter to use an xtra attribute (eg. DoorAngle, DoorWidth,etc) , and refer the standard attributes to them(eg. RotZ=DoorAngle). do the Animatefunction on that custom attribute.(eg. OnClick=Animate(“DoorAngle”,0,50,90)  
Btw. You can animate more then one attributes with one ‘OnClick’, (‘;’ as seperator)  
AnimateCustom gives you some control over the speed of the animation.  
Check this thread:

> [@Componentes Dinamicos](https://forums.sketchup.com/t/componentes-dinamicos/67321/4):
>
> like so? This is tricky and will involve some trigonometry. The top window is not that difficult, though, the position of the bottom depends on the angle of the upper. Assumptions: both angles are the same… both windows are 'animated in the o’clock attribute, divided with a separator ; you might wanna check the [Animator](https://sketchucation.com/pluginstore?pln=Animator) extension… here is the file, have fun! [windowfold.skp](https://forums.sketchup.com/uploads/short-url/awHqNnLZrnwDjOUE80hszkuBkRr.skp) (261.1 KB)

---

<div class="post-metadata">

**Author:** ![james74](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@james74](https://forums.sketchup.com/u/james74)\
**Post date:** [September 24, 2018, 12:30pm UTC](https://forums.sketchup.com/t/simple-swing-door-onclick/77387/4 "2018-09-24T12:30:17Z")

</div>

Thank you so much for your help.

I have now created a custom field against each sub-component and set the click animation on the parent.

Now when I click, the doors open.

Thank you again, that has solved it for me.
