Elegant way to turn a collection instance to a mesh?

I’m currently about to create some Add-on that is supposed to use collections to turn them in some single meshes.
I’m currently at a stage where I would have to traverse through all the objects that are part of the collection (and sub collections / instances recursively), apply all modifiers and scales, keep track of materials, UVs and so on then use the join operator and such to join them together.

To me it feels like having to manage all this manually in python is overkill (and could also become potentially slow for larger scenes) but since collection instance to some extent behave like single meshes I’m wondering if I overlooked some method to exploit that fact and extract a single new mesh just from the information a collection instance got or if there is any other more elegant route than the one I’m just about to follow.


I have nothing to offer in the way of help, all I can say is that as a user, I’d appreciate this addon.

Collection instances are powerful but annoying to use and unfinished in my opinion. You should be able to use them parametrically in modeling.

Is the plan to update the meshes in real time? For level design I’d appreciate an addon that could take a collection instance and make a mesh I can use on a curve or something and any changes made to the collection propagate to the mesh.

Since I’m currently experimenting and discovering what the API offers me I cannot predict what I will add for sure but you might want to check out the smart join addon for blender 2.7, I want to kind of rebuild the functionality but instead of relying on parented object’s I want to make full use of the collection system for 2.8.

I made some progress and I figured out that using the operators seems to save me from dealing with manually traversing objects and such but with the drawback that it is no understatement that it is quite a mystery how to setup the context correctly for that as the warning shows in the documentation. I hope Epic’s money for example can also be used to for example provide better interfaces to functions that are actually already implemented as user operators.

First quick and dirty test script by no means feature complete:

One click is not the worst workflow, but obviously the ideal is no further input from the artist once he has made a bunch of instances.

I assume that you are already already using the make_duplicates_real operator, but are you using the ‘use_base_parent’ property? If so, you know what the instance’s name was- so you also know the name of the empty that serves as a parent once you complete this operation. From there it’s just a matter of getting all of the mesh objects linked to it and doing the rest.

Also, you might not be aware that it’s not necessary to traversing the modifier stack if all you want to do is apply everything. The convert operator already does this (yes, it converts a mesh into a mesh- i found it odd when I found out as well).

I agree, it would be super handy if they had a “flatten instance to single mesh” operator (in Modo we called this “freeze mesh”, add that to the python python papercuts thread, or make a feature request at RCS and you’ll have my upvote.

Thanks, that’s more or less what I ended up with, just felt a bit messy at the first place having to deal with selections / using context overrides for this. But for now it turned out to work quite good.

I sketched similar, complementary proposals in a new tread, but “at a more radical level”