I have a very basic script which I hope to do a couple things at once, but I am stuck at removing the constraint, and the group_link fails.
What am I doing wrong? Note: the group does exist, it even has 1 object in it just to be sure. :)
Everything here works, now only to solve the constraint removal. :( :)
import bpy for obj in bpy.context.selected_objects: ### get last 3 digits from object name and save them as objNumber objNumber = obj.name[-3:] ### set object as Active bpy.context.scene.objects.active = bpy.data.objects['Cube.'+objNumber] ### add Boolean and set the target to Cube bpy.ops.object.modifier_add(type='BOOLEAN') obj.modifiers["Boolean"].object = bpy.data.objects["Cube"] ### remove current constraints and add Copy Transforms, with target set to an Empty with the same number as original object bpy.ops.object.constraint_delete() bpy.ops.object.constraint_add(type='COPY_TRANSFORMS') bpy.context.object.constraints["Copy Transforms"].target = bpy.data.objects["Empty."+objNumber] ### moving to layer 10 and grouping to group Ties #bpy.context.space_data.context = 'OBJECT' obj.layers = True obj.layers = False bpy.ops.object.group_link(group='Ties')