get_object_by_name() returning a not found error
09 February 2016 15:52
Hi,
I'm very new here so forgive my lack of knowledge.
When I typed this in my javascript code:
This returns an error saying:
B4W ERROR: get object selectedPlane: not found.
Now there is 'selectedPlane' in my blend file. I'm probably overlooking the obvious but is there something I'm missing? Possibly in the blend file too? Thanks in advance
I'm very new here so forgive my lack of knowledge.
When I typed this in my javascript code:
m_scenes.hide_object(m_scenes.get_object_by_name("selectedPlane"));
This returns an error saying:
B4W ERROR: get object selectedPlane: not found.
Now there is 'selectedPlane' in my blend file. I'm probably overlooking the obvious but is there something I'm missing? Possibly in the blend file too? Thanks in advance
09 February 2016 16:25
Did you dynamically load "selectedPlane"? If you use dynamic loading this topic helps you.
Blend4Web Team
kirill@blend4web.com
kirill@blend4web.com
09 February 2016 17:29
11 February 2016 13:21
Thanks for your replies
I have attached the blend file from the furnishing the room tutorial. It has an object called 'spawner'. It works fine for their example but if I copy this object into my scene it doesn't pick up on it. Please let me know if you can find an answer.
Did you dynamically load "selectedPlane"? If you use dynamic loading this topic helps you.Yes, I just followed the furnishing the room tutorial.
I have attached the blend file from the furnishing the room tutorial. It has an object called 'spawner'. It works fine for their example but if I copy this object into my scene it doesn't pick up on it. Please let me know if you can find an answer.
12 February 2016 12:53
23 February 2016 11:38
I can give you a more detailed example:
Here I'm searching for an object with name - obname. And _objs is storing all the objects in the scene. I am then looking for the object in the array and printing its name out. Please check the screenshot attached. The objects is found and its name is printed. But when I use get_object_by_name() it says that its not found.
Any help would be appreciated. :)
var obname = "ItaliaMateArmchairMain";
var _objs = [];
_objs = m_scenes.get_all_objects("MESH");
for(var i = 0 ; i < _objs.length; ++i)
{
if(_objs[i].name == obname) {
console.log(_objs[i].name);
var materials = m_mat.get_materials_names(m_scenes.get_object_by_name(_objs[i].name));
console.log(materials);
}
}
Here I'm searching for an object with name - obname. And _objs is storing all the objects in the scene. I am then looking for the object in the array and printing its name out. Please check the screenshot attached. The objects is found and its name is printed. But when I use get_object_by_name() it says that its not found.
Any help would be appreciated. :)
24 February 2016 16:07
25 February 2016 08:19
25 February 2016 10:23
No, not get_object_by_name(), but get_object_name(_objs[j]). They're easy to confuse .
25 February 2016 11:28