Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created January 7, 2016 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/82cc80f054b137d363d3 to your computer and use it in GitHub Desktop.
Save zeffii/82cc80f054b137d363d3 to your computer and use it in GitHub Desktop.
import bpy
def execute(self, context):
target_obj = context.active_object
tool_objs = [o for o in context.selected_objects if o != target_obj]
BOOL = 'BOOLEAN'
# first add them.
for obj in tool_objs:
bool_mod = target_obj.modifiers.new(name='difference_' + obj.name, type=BOOL)
bool_mod.operation = 'DIFFERENCE'
bool_mod.object = obj
# then apply them individually.
for modifier in target_obj.modifiers:
bpy.ops.object.modifier_apply(modifier=modifier.name)
execute(None, bpy.context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment