Print at Dec 20, 2025, 11:24:34 PM

Posted by sjb007 at Jun 20, 2022, 11:37:52 AM
Re: Add "o" to OBJWriter output
Is it possible to check/get the parent groups from a HomePieceOfFurniture?

I'm quite sure you can't get the parent directly. However you can get the child from the parent, so you can iterate over all groups to build a child->parent map, and use it later to query the parent from the child.
Keep in mind that groups can be nested, so if you want to recreate the hierarchy you have to prepend the parent name in a loop until the object has no more ancestors.
Another approach could be to retrieve the objects using Home.getSelectableViewableItems(), which returns all the non-grouped objects + the groups, then you can itearate over the items and if you find a group dive into it using a recursive method.

I was afraid of that, but good to have better eyes than mine confirm it. Guess I have to figure out more Java-isms. Ugh. At least the HomePane.OBJExporter class already has code to iterate through the objects using getSelectableViewableItems/getSelectedItems. Reading the code the structure looks flat, so there shouldn't need to be any recursion. Just create a HashMap child:parent, then loop over the hashmap to build the parent groups when creating the full "path". Nothing too complicated.

So when I get the SH3D bit finished, would you mind taking a look over it? It'll be pretty short as patches go, but I'm sure I've done some bits in bad way. (i.e. that there is a Javonic way, just like there is a Pythonic way, and I'm forcing Pythonic style into Java. biggrin )