I'm trying to parent an object to a specific bone. I need to assign 100% bone weights to all vertices, to be able to read this as a skeletal mesh in Unreal Engine. I'm using this code:
ob= bpy.data.objects['Cube'] arma = bpy.data.objects['Armature'] ob.parent = arma ob.parent_bone = "Bone" ob.parent_type = 'BONE'
... It works, but the object changes its transform. How can I parent it without changing transform of the object? Here is my simple test blend file: http://pasteall.org/blend/index.php?id=46227
Please click the 'Run Script' button to see the issue.
I would be grateful for some hints. I've tried the matrix multiplication (matrix_world.inverted()), but it doesn't work for bones.
For example, Ctrl + P in editor does it properly - it parents an object to a bone without moving it. Thanks!
Update: I've also thought about assigning all the object's vertices to a bone with 100% weight - but I can't find any info on this one, I'm afraid that it's not possible? :(