# Components inside a Component

**URL:** <https://forums.sketchup.com/t/components-inside-a-component/133960>\
**Category:** Dynamic Components\
**Tags:** components\
**Created:** [August 19, 2020, 3:07pm UTC](https://forums.sketchup.com/t/components-inside-a-component/133960 "2020-08-19T15:07:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomfabriek](https://avatars.discourse-cdn.com/v4/letter/t/e95f7d/32.png) [@tomfabriek](https://forums.sketchup.com/u/tomfabriek)\
**Post date:** [August 19, 2020, 3:07pm UTC](https://forums.sketchup.com/t/components-inside-a-component/133960/1 "2020-08-19T15:07:43Z")

</div>

I have a question.  
I created a dynamic component (cabinet with drawers)  
And I want to anymate the drawers.  
But de component of the drawers will not take the attributes of the maincomponent (cabinet)  
Can I fix that?[OK\_2POTL.skp](https://forums.sketchup.com/uploads/short-url/qytx0gE0fBZnQdAuNdJc6AI0Jvc.skp) (4.2 MB)[OK\_2POTL\_With\_animation.skp](https://forums.sketchup.com/uploads/short-url/4NTOXxiT2wjEh9sQiebXuPC3Hyd.skp) (4.2 MB)

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [August 19, 2020, 6:25pm UTC](https://forums.sketchup.com/t/components-inside-a-component/133960/2 "2020-08-19T18:25:55Z")

</div>

> [@tomfabriek](#):
>
> And I want to anymate the drawers.

They can only be manually animated with a mouse click.

How do you wish to animate them ? All at once or separately ?

> [@tomfabriek](#):
>
> But de component of the drawers will not take the attributes of the maincomponent (cabinet)

If you wish to animate each drawer separately, then the main component must not have an **`onClick`** attribute.

_Each_ drawer subcomponent would then each have their _own_ **`onClick`** attribute.

> [@tomfabriek](#):
>
> Can I fix that?

We cannot know unless you add the DC file to the first post. (Use the pencil icon to edit.)

---

<div class="post-metadata">

**Author:** ![tomfabriek](https://avatars.discourse-cdn.com/v4/letter/t/e95f7d/32.png) [@tomfabriek](https://forums.sketchup.com/u/tomfabriek)\
**Post date:** [August 21, 2020, 9:47am UTC](https://forums.sketchup.com/t/components-inside-a-component/133960/3 "2020-08-21T09:47:51Z")

</div>

> [@DanRathbun](#):
>
> only

> [@DanRathbun](#):
>
> They can only be manually animated with a mouse click.
> 
> How do you wish to animate them ? All at once or separately ?

I prefer separatly

---

<div class="post-metadata">

**Author:** ![tomfabriek](https://avatars.discourse-cdn.com/v4/letter/t/e95f7d/32.png) [@tomfabriek](https://forums.sketchup.com/u/tomfabriek)\
**Post date:** [August 21, 2020, 9:49am UTC](https://forums.sketchup.com/t/components-inside-a-component/133960/4 "2020-08-21T09:49:51Z")

</div>

> [@DanRathbun](#):
>
> If you wish to animate each drawer separately, then the main component must not have an **`onClick`** attribute.
> 
> _Each_ drawer subcomponent would then each have their _own_ **`onClick`** attribute.

Thanks for the info,  
I have able to do that, but the measurements will not scale when I adjust the measurements of the maincompontent… because the don’t link

---

<div class="post-metadata">

**Author:** ![tomfabriek](https://avatars.discourse-cdn.com/v4/letter/t/e95f7d/32.png) [@tomfabriek](https://forums.sketchup.com/u/tomfabriek)\
**Post date:** [August 21, 2020, 9:51am UTC](https://forums.sketchup.com/t/components-inside-a-component/133960/5 "2020-08-21T09:51:12Z")

</div>

> [@DanRathbun](#):
>
> We cannot know unless you add the DC file to the first post. (Use the pencil icon to edit.)

I put the sketchupfile in the first post

---

<div class="post-metadata">

**Author:** ![tomfabriek](https://avatars.discourse-cdn.com/v4/letter/t/e95f7d/32.png) [@tomfabriek](https://forums.sketchup.com/u/tomfabriek)\
**Post date:** [August 21, 2020, 5:26pm UTC](https://forums.sketchup.com/t/components-inside-a-component/133960/6 "2020-08-21T17:26:36Z")

</div>

Is there a way to link the subcomponent to the main component

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [August 21, 2020, 5:28pm UTC](https://forums.sketchup.com/t/components-inside-a-component/133960/7 "2020-08-21T17:28:18Z")

</div>

> [@tomfabriek](#):
>
> I have able to do that, but the measurements will not scale when I adjust the measurements of the maincompontent… because the don’t link

Yes, you are using the top level DC name in a grandchild (_kleinkind_) component formula.  
Nested DC objects can only see `=parent!` (_ouder_) or sibling (_broer of zus_) objects.

To get attributes from grandparent (_grootouder_) you need to **pass them down** (_geef ze door_) to the parent (_ouder_) … like passing genes (_zoals passerende genen_) …

In grandparent `"OK_2potl"` …

```auto
voeg "=0.2cm"

```

In `"Lade_Boven"` parent

```auto
ouder_voeg "=parent!voeg"

```

In `"Lade_Deur_Boven"` grandchild (_kleinkind_) …

```auto
X "=parent!ouder_voeg"

```

---

<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:** [August 25, 2020, 3:49pm UTC](https://forums.sketchup.com/t/components-inside-a-component/133960/8 "2020-08-25T15:49:41Z")

</div>

You also need to break down the sliding part and the fixed part of the runners(!)  
You can create a separate component for all the parts of the top and lower drawer and add the ‘OnClick’ to that or combine several ‘OnClick’ formulas separated by ‘;’ to the lade fronts only.  
(Eg. OnClick=ANIMATE(“Onderdeel\_boven\_lade!X”,0,-40,0) ; ANIMATE(“Ander\_onderdeel!X”,0,-40,0)
