I have this Boolean operator which adds a Boolean to the active object and adds the second in order to the object property
but this wont more than once because the second modifier added wont be dif
it would be dif.001
How do i automate this name issue
class BoolOp(Operator):
"""Quick Booelan Operation"""
bl_idname = "extorctools.boolop"
bl_label = "Bool Op"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
target = bpy.context.active_object
lis = bpy.context.selected_objects
cutter = []
for x in range(len(lis)):
if len(lis) == 1:
raise Exception("2 Objects must be selected")
elif not lis[x] == target:
cutter.append(lis[x])
break
try:
target.modifiers.new(name = f"dif" , type = 'BOOLEAN')
target.modifiers['dif'].object = cutter[0]
except:
pass
return {'FINISHED'}
What i want to be able to do is to do something like this target.modifiers[the.most.recent.modifier.of.type.BOOLEAN].object = cutter[0]
obj.modifiers.new(...)returns the modifier. Usenew_mod = obj.modifiers.new(...)– Gorgious Mar 28 '21 at 07:56