Forum

get_object_by_name() returning a not found error

25 February 2016 11:49 #7721
It returns - ItaliaMateArmchairMain
Same as before.

OK, it seems legit.
Please, try the following code:
m_scenes.get_object_by_name(_objs[i].name, m_scenes.DATA_ID_ALL);
Blend4Web Team
25 February 2016 12:20 #7722

m_scenes.get_object_by_name(_objs.name, m_scenes.DATA_ID_ALL);

Yes!!! That worked, thank you so much. Could you please explain why I had to do this for it to work?
25 February 2016 13:02 #7724
Yes!!! That worked, thank you so much. Could you please explain why I had to do this for it to work?

The second parameter is needed for dynamically loaded objects. You can load a single scene many times, so there would be many objects with the same name. Data_id helps to uniquely identify these objects. If an object belongs to the main scene its data_id is 0, objects from the first dynamically loaded scene have data_it set to 1, from the second - 2 and so on.

You can pass a certain data_id if you know what object you want to get, or pass DATA_ID_ALL to search through all these objects regardless of data_id.

There is also a corresponding method to retrieve this id from an object: get_object_data_id
Blend4Web Team
25 February 2016 13:22 #7725
I see! Thanks for your explanation!! Makes sense to me now
 
Please register or log in to leave a reply.