Dynamic component move then move back to original pos?

Hi. I’m having trouble with a seemingly simple component, a cabinet door, which I want on click to rotate but also to move inwards when open so it doesn’t go outside of the cabinet itself. This rotates the door correctly, but moves the door infinitely to one side (it should go back where it was when closed):


D=LenX (door thickness)
POS=Y (door position)

Any ideas?

Use a time line, (steps of door swing and movement) and conditions for change.
I use animatecustom for timelines as it allows a chosen time period

door return pocket.skp (17.8 KB)

Thanks @pcmoor. While a pocket door will be handy, what I’m actually after is a normal door that only rotates. The rotation, however, should simulate a hinge that keeps the opened door within the cabinet dimension. Like this: https://www.ikea.com/gb/en/p/utrusta-hinge-20204647/ So, it’s not just a rotation but rotation with slight movement inwards. Thanks.

door_test.skp (184.6 KB)

door_test.skp (184.3 KB)

no need to put the x in the formula, as it will keep updating, moving it by extra 2cm (door thickness)

Sorry, can you save down to v2019? Thanks.

door_test.skp (183.0 KB) :innocent:

Thanks. And how to make the object do that in any place, when moved or copied?

Generally it would be contain and controlled within another DC, so to make it a independent door, one can wrap it with another component.
door_test.skp (193.7 KB)

Yes, but then if you click on any copy, all copies react which is not the preferred outcome. Is there a way to update position of the component after first click (door opened), so the next move (door closed) takes it into account?

no, as you are referencing the position attribute which in turn updates.
a fix for a copy, right click the parent (wrapper) and make unique

door_test.skp (76.7 KB)

Having said that, I recall a method, I added another attribute which toggles the sign of the thickness and uses that on the position

Perfect! That’s in line what I wanted to achieve. Thanks.