What is the correct way to get parent item in outliner view. I can get parent item but in some cases it not works or get unexpected results.
e.g. this is the outlier view (First Image):
As in the image given the selected item is Collection
. When, I get parent of the item, I get Scene Collection
which is correct.
In this way, If i want to get parent of Cube
, I get Collection
, which is correct. But when i get the parent of following item (View Layer
), I get wrong result (Second Image).
In this case the parent returned is Scene
. But I think View Layers
must be the parent of View Layer
. How i get first parent (first upper tree element).
I am using this code in C:
TreeElement get_parent_item(TreeElement *te_temp) {
if (te_temp->parent) {
te_temp = te_temp->parent;
printf(te_temp->name);
}
return *te_temp;
}
Any confusion, comments me… Please helps me.