Forum

Get the selected object's parent

24 June 2015 18:57
Hi, I'm trying to get a selected object's parent, but it always returns NULL. What am I doing wrong?
I'm using get_object_dg_parent.

I'm successfully using get_object_children to get the children, but the opposite won't work!
24 June 2015 19:57
Hello and welcome to our forum!

Unfortunately, get_object_dg_parent() is not the opposite of get_object_children(). It's completely different thing, because it returns dupli group parent for given object e.g some EMPTY used to duplicate linked group.

There is no get_object_parent() because it's not very efficient to do search for parent among all objects located on the scene.

If you still need it you can implement it yourself by iterating over all possible objects (returned by get_all_objects(), specify type here to limit search set) and compare their children with your original object.
24 June 2015 20:22
29 January 2016 15:30

If you still need it you can implement it yourself by iterating over all possible objects (returned by get_all_objects(), specify type here to limit search set) and compare their children with your original object.


What are the 'types' that I could use to limit the search?
29 January 2016 18:51
Ответ на сообщение пользователя amiarun
What are the 'types' that I could use to limit the search?
These are Blender's types: "MESH", "CAMERA", "EMPTY", "SPEAKER", "LAMP".
And a new "LINE" type which was added in the 16.01.

We will add this info to API doc.
 
Please register or log in to leave a reply.