I want to clear a scene's master collection in order to ensure I am working with an empty collection before I run my script which will build the scene for me.
I search for answers on how to achieve that and they suggest selecting all desired objects and triggering the deletion operation with that selection. I attempted to adapt that code, but found that the object of type FONT
actually lacks the select
property/attribute and as a result I can't include my Texts in the selection to clear them.
# Clear all objects in the master collection to reset to a blank scene
for object in bpy.data.scenes[0].collection.objects:
print(object.type)
if hasattr(object, 'select'):
object.select = True
bpy.ops.object.delete()
Is there an alternative way of selecting Texts? Or even better, can I clear the collection completely without "macroing" it by creating a selection and calling the delete operation?