I asked this on stack exchange, but the “exchange” there makes me think that it’s probably more appropriate for a discussion here. If it’s not, please direct me to where it may be–as I am getting a lot of resistance to discussing it on stack exchange.
When building tools and processes, it’s almost always crucial to know what the last object created is. Many functions which create objects of various types in Blender don’t return those objects, nor is there an ordered list of any type accessible which can be used to discover what may have been created recently.
It was suggested that
C.object is a good way to find this, but there are ways to create objects which do not place them in the current context, for one, and for two, it’s possible to change context without creating anything, which means that the context will not report the last created object.
The only way I can think of to reliably learn what object(s) a function may have created is to compare lists of all scene objects before and after running the function. This is not efficient, and seems like a very nasty and cumbersome workaround. And of course sorting through the difference might be fraught, if the function created more than one object which will not be reported in any order. This would imply additional detective work in some instances, so there still wouldn’t be a universal way to learn, in order, what objects were created recently.
It’d be great to know if there were a simpler, more efficient, more reliable way to discover what’s been created in the scene, in order of creation.