Is it possible to assign modifier parameters with python? I have 10 objects (labeled object.000-object.009) and 10 armatures (armature.000-armature.009). I want to be able to use a script to add an armature modifier to each object and assign the armature parameter according to my naming convention (object.000:armature.000, etc), then apply the modifier so the object maintains its new shape. Is this even possible?
In looking through the API, I see it is possible to set the parameter through Python, however I can’t figure out if it is possible to automate the process according to my naming convention. Can anyone confirm or deny if it is possible to use a variable of some sort to automatically select the armature that has the matching number?
Assuming your armatures are armature object names:
import bpy
for ob in bpy.context.scene.objects:
if ob.type == 'MESH':
mod = ob.modifiers.new(name="", type='ARMATURE')
mod.object = bpy.data.objects.get("armature." + ob.name.partition(".")[2])
Thank you CoDEmanX, it works flawlessly.