# How do I get a child (by name or id) of imported file?

**URL:** <https://forum.babylonjs.com/t/how-do-i-get-a-child-by-name-or-id-of-imported-file/10323>\
**Category:** Questions\
**Created:** [April 25, 2020, 11:05pm UTC](https://forum.babylonjs.com/t/how-do-i-get-a-child-by-name-or-id-of-imported-file/10323 "2020-04-25T23:05:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![franmx](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/franmx/32/7483_2.png) [@franmx](https://forum.babylonjs.com/u/franmx)\
**Post date:** [April 25, 2020, 11:05pm UTC](https://forum.babylonjs.com/t/how-do-i-get-a-child-by-name-or-id-of-imported-file/10323/1 "2020-04-25T23:05:01Z")

</div>

Hi, I imported a glb file and need to access one of its childs to assign a trigger. It works fine for the first object (let’s call it sphereH).  
Using

`var assignATrigger = scene.getMeshByName("sphereH");`

When I load another file and also need to access the child of that, which happens to have the same name is not activating the trigger. I think scene is giving me back first sphereH, or in any case it doesn’t work like that.

Is there something like scene. **objectA**.getMeshByName(“sphereH”); ?

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [April 26, 2020, 12:29am UTC](https://forum.babylonjs.com/t/how-do-i-get-a-child-by-name-or-id-of-imported-file/10323/2 "2020-04-26T00:29:19Z")

</div>

Since mesh names are not necessarily unique scene.getMeshByName will only get the first in the meshes array. If you made the files you will need to rename them. Otherwise you will need to find and record their array index and then use that as a reference in you project code.

---

<div class="post-metadata">

**Author:** ![franmx](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/franmx/32/7483_2.png) [@franmx](https://forum.babylonjs.com/u/franmx)\
**Post date:** [April 26, 2020, 2:58pm UTC](https://forum.babylonjs.com/t/how-do-i-get-a-child-by-name-or-id-of-imported-file/10323/3 "2020-04-26T14:58:50Z")

</div>

Thanks JohnK, I think I can’t rename as those object are loaded with different number (could be 1 object or 30, for example). Second option sounds better, In inspector the hierarchy is:

- root
  - mesh01
  - mesh02
  - **sphereA**

Can I get the array index with that information?

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [April 26, 2020, 5:06pm UTC](https://forum.babylonjs.com/t/how-do-i-get-a-child-by-name-or-id-of-imported-file/10323/4 "2020-04-26T17:06:04Z")

</div>

scene.meshes should give you what you want.
