I’m developing my own export script, which works fine to export the currently selected active object to a file in my own custom format. That’s fine.
I need to expand on it now so that it can save multiple objects. So my idea was that if the current object is an empty then it could iterate through the empty’s children and save each object to the file (using the function that exports a single object that I’ve got which works, so that’s already covered).
The problem is that, with the API, getting the active object on an empty just gives me a NoneType.
I thought of doing it backwards and iterating through all the scene’s objects, if the active object is None, seeing if its parent was the selected empty, and then saving it to the file. But I can’t get this to work at all, and it feels like a very hack-ish solution to the problem anyway.
Is there not a way with the Python API to, you know, access the scene hierarchy as seen in the Outliner window?
That is, somehow check if the active selection is an empty and, if it is, then get a list of its child objects, so I can write each of them out to the file.
And, if it isn’t, because the active selection is just a singular object, then I can skip that and just write the object directly (as files with a single object in them are valid too, but I also need this “one or more objects” functionality too, using the empty to effectively mark out which objects form the set of objects that need to be written to the file).
So, in a sentence, how would I do “if selected object is an empty, then get a list of its children” (where by “children” I mean the objects that are directly under it in the outliner hierarchy - the objects to which the empty are its parents)?