in order to speed up the process of configuring a ragdoll humanoid with Blender, i use an addon that creates empties on the head of each bone aligned to the bone (Bonera), and other that creates meshes on the same location but with already configured rigid bodies and rigid body constraints (Rigid Body Gen). Then i manually copy the transforms from the empties to the meshes so they line up one by one. How could i do this for all selected meshes at once with a script? Like for the selected meshes, copy loc and rot from the empties using their name as reference (copy loc/rot from bone_[name] to joint_[name])
Asked
Active
Viewed 43 times
1 Answers
0
From the information you've given, only this simple script can be derived. Hope it helps. If it's not working, please provide more precise information about your scene setup.
import bpy
get all selected objects
for selected_obj in bpy.context.selected_objects:
# only consume meshes
if selected_obj.type == 'MESH':
# get bone and joint object with mesh name
bone_obj = bpy.data.objects['bone_' + selected_obj.name]
joint_obj = bpy.data.objects['joint_' + selected_obj.name]
# copy loc and rot
joint_obj.location = bone_obj.location
joint_obj.rotation_euler = bone_obj.rotation_euler
taiyo
- 3,384
- 1
- 3
- 18
bone_obj = bpy.data.objects['bone_' + obj.name.replace("joint_", '')]– Jh0nny Aug 08 '23 at 03:10obj.matrix_worldattribute, see this answer https://blender.stackexchange.com/questions/209398/how-to-copy-rotation-from-active-to-selected-in-python. – taiyo Aug 08 '23 at 11:39