Is it possible to list, in Python, all the subtracted objects?

I've got a big wall (Wall) with 3 holes (Cube, Cube.001, Cube.002). I made the holes with a boolean difference and I wish to list the names of these objects.

In this case I want to list:

list = ['Cube', 'Cube.001', 'Cube.002']

Thanks in advance!

enter image description here


This script will loop through the modifiers on the specified object, check if they are boolean modifiers, check if the modifier has an object specified, and if it does it will print the name of the object being used:

import bpy

#Object with modifiers
object = bpy.data.objects['Cube']       

for modifier in object.modifiers:
    #Check if modifier is boolean AND has a boolean object selected  
    if modifier.type == "BOOLEAN" and modifier.object:
        print (modifier.object.name)

You could of course .append object names into a list instead of printing.

Alternatively, you can use a list comprehension version which does exactly the same, except this adds all object names to a list before printing:

objects = [mod.object.name for mod in object.modifiers if mod.type=="BOOLEAN" and mod.object]
print (objects)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.