# How to move meshes from imported obj file?

**URL:** <https://forum.babylonjs.com/t/how-to-move-meshes-from-imported-obj-file/12487>\
**Category:** Questions\
**Tags:** blender\
**Created:** [July 14, 2020, 5:53pm UTC](https://forum.babylonjs.com/t/how-to-move-meshes-from-imported-obj-file/12487 "2020-07-14T17:53:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![loscar9](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/loscar9/32/9748_2.png) [@loscar9](https://forum.babylonjs.com/u/loscar9)\
**Post date:** [July 14, 2020, 5:53pm UTC](https://forum.babylonjs.com/t/how-to-move-meshes-from-imported-obj-file/12487/1 "2020-07-14T17:53:39Z")

</div>

I am pretty new to babylon and web graphics but I think it is the right tool for what I want to do. I have managed to import obj file into babylon but I can’t manage to access/modify the meshes from this file individually?

I have tried to access them by scene.getMeshByName and byID and UniqueID (got from sandbox)

I have also tried to convert the obj into a .babylon file but the Blender plugin fails with an error hence why I am dealing with obj files.

```
Traceback (most recent call last):
File "...\Blender Foundation\Blender\2.83\scripts\addons\babylon_js\ __init__.py", 
line 65, in execute
exporter.execute(context, self.filepath)
File "...\Blender Foundation\Blender\2.83\scripts\addons\babylon_js\json_exporter.py", line 115, in execute
mesh = Mesh(object, scene, self)
File "...\Blender\2.83\scripts\addons\babylon_js\mesh.py", line 158, in __init__
mat.processImageTextures(bpyMesh)
File "...\Blender Foundation\Blender\2.83\scripts\addons\babylon_js\materials\material.py", line 79, in processImageTextures
tex.process(self.exporter, True, bpyMesh)
File "...\Blender Foundation\Blender\2.83\scripts\addons\babylon_js\materials\texture.py", line 84, in process
self.uvMapName = bpyMesh.data.uv_layers.active.name
AttributeError: 'NoneType' object has no attribute 'name'

location: <unknown location>:-1

```

Here is my obj file [Gofile](https://gofile.io/d/HQlB46)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [July 14, 2020, 6:14pm UTC](https://forum.babylonjs.com/t/how-to-move-meshes-from-imported-obj-file/12487/2 "2020-07-14T18:14:49Z")

</div>

Hello and welcome 😉

can you repro your issue in the Playground?

---

<div class="post-metadata">

**Author:** ![loscar9](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/loscar9/32/9748_2.png) [@loscar9](https://forum.babylonjs.com/u/loscar9)\
**Post date:** [July 15, 2020, 10:13am UTC](https://forum.babylonjs.com/t/how-to-move-meshes-from-imported-obj-file/12487/3 "2020-07-15T10:13:13Z")

</div>

[https://www.babylonjs-playground.com/#5WM246#1](https://www.babylonjs-playground.com/#5WM246#1)

I think it explains what I’m trying to do

---

<div class="post-metadata">

**Author:** ![wulf11](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wulf11/32/2196_2.png) [@wulf11](https://forum.babylonjs.com/u/wulf11)\
**Post date:** [July 15, 2020, 11:51am UTC](https://forum.babylonjs.com/t/how-to-move-meshes-from-imported-obj-file/12487/4 "2020-07-15T11:51:00Z")

</div>

Hey @loscar9 !

It seems that the “ **StanfordBunny.obj** ” in your example does not contain multiple meshes!  
So you won’t be able to move the “ears” mesh, because there is no separation in it.

You can check the scene via the inspector. Just click on the options-icon in the playground (top right) and click on “inspector”. You can then check the nodes of the scene.

I may suggest you to replicate your example with the “ **candle.babylon** ” file. This one has multiple meshes in it.

---

<div class="post-metadata">

**Author:** ![loscar9](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/loscar9/32/9748_2.png) [@loscar9](https://forum.babylonjs.com/u/loscar9)\
**Post date:** [July 15, 2020, 3:47pm UTC](https://forum.babylonjs.com/t/how-to-move-meshes-from-imported-obj-file/12487/5 "2020-07-15T15:47:50Z")

</div>

My .obj (linked first post) has multiple nodes in it, so how do I access them individually via getMeshBy\_? I will try with candle like you suggested when I get back to my desk

---

<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:** [July 15, 2020, 5:52pm UTC](https://forum.babylonjs.com/t/how-to-move-meshes-from-imported-obj-file/12487/6 "2020-07-15T17:52:54Z")

</div>

Would [https://doc.babylonjs.com/api/classes/babylon.scene#getnodebyname](https://doc.babylonjs.com/api/classes/babylon.scene#getnodebyname) help?

---

<div class="post-metadata">

**Author:** ![wulf11](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wulf11/32/2196_2.png) [@wulf11](https://forum.babylonjs.com/u/wulf11)\
**Post date:** [July 15, 2020, 10:36pm UTC](https://forum.babylonjs.com/t/how-to-move-meshes-from-imported-obj-file/12487/7 "2020-07-15T22:36:24Z")

</div>

@loscar9

Well I took some time and tested a PlayGround with the file you provided.  
Btw you can easily use external assets via DropBox (if you have an account there).

Check this:  
[https://doc.babylonjs.com/resources/external\_pg\_assets#from-dropboxcom](https://doc.babylonjs.com/resources/external_pg_assets#from-dropboxcom)

I used the **BABYLON.SceneLoader.ImportMesh** -Method. like this:

```
 BABYLON.SceneLoader.ImportMesh(
        "",
        "https://dl.dropbox.com/s/s8qybdnnsk5w36r/",
        "website.obj",
        scene,
        function (meshes) {          
            scene.createDefaultCameraOrLight(true, true, true);
            scene.createDefaultEnvironment();

             //log the name of the meshes we just imported
            for(var i = 0; i < meshes.length; i++){
                console.log(meshes[i].name);
            }

           var wallsMesh = scene.getMeshByID("walls");
           wallsMesh.isVisible = false;
        }
    );

```

**Note!**  
I deleted the website.obj, so the example won’t work with my link anymore…so feel free to host it yourself or try it in your local dev-environment!

I think your problem was not the **scene.getMeshByID()**-method. I guess you placed the call in the wrong place?! You have to make sure that everything is loaded before accessing the mesh (e.g. via the onSucess?-callback function in the ImportMesh()-method).

---

<div class="post-metadata">

**Author:** ![loscar9](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/loscar9/32/9748_2.png) [@loscar9](https://forum.babylonjs.com/u/loscar9)\
**Post date:** [July 16, 2020, 12:38pm UTC](https://forum.babylonjs.com/t/how-to-move-meshes-from-imported-obj-file/12487/8 "2020-07-16T12:38:26Z")

</div>

It works! Thank you, if i create a variable for a certain mesh from this, can I access it from anywhere and it will update the mesh?

---

<div class="post-metadata">

**Author:** ![wulf11](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wulf11/32/2196_2.png) [@wulf11](https://forum.babylonjs.com/u/wulf11)\
**Post date:** [July 17, 2020, 8:09am UTC](https://forum.babylonjs.com/t/how-to-move-meshes-from-imported-obj-file/12487/9 "2020-07-17T08:09:01Z")

</div>

You are welcome 🙂  
If you want to use the variable from anywhere, then declare it outside of the onSucess-function!  
Otherwise the scope will be only in the function!

Check this:  
[https://www.w3schools.com/js/js\_scope.asp](https://www.w3schools.com/js/js_scope.asp)

So I would declare a variable **outside** and assign it **in** the function! So you can use it anywhere 🧐

---

<div class="post-metadata">

**Author:** ![musk](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/musk/32/17156_2.png) [@musk](https://forum.babylonjs.com/u/musk)\
**Post date:** [April 7, 2021, 7:06am UTC](https://forum.babylonjs.com/t/how-to-move-meshes-from-imported-obj-file/12487/10 "2021-04-07T07:06:36Z")

</div>

Have you solved Blender export babylon file error ? I met the same situation
