3
$\begingroup$

I'll try writing this the best I can. I want to be able to apply a copy transform on Rig 1 so it can be controlled by Rig 2. Both rig has the same bone names etc. Instead of manually going to each bone and apply a copy transform constraint. I would like to be able to run a script or something where it does it automatically. Is this possible at all? I will do my best to help answer any questions or provide blend file if needed.

https://drive.google.com/file/d/1yAbTtWaeXYSN9i9qeyneAJo-C12S3cX3/view?usp=sharing

$\endgroup$

1 Answer 1

2
$\begingroup$

This code is an example of how to do that, but I've left out three settings because I didn't know if the default was enough

import bpy

src = bpy.data.objects['src']
dst = bpy.data.objects['dst']

for bone in dst.pose.bones:
    bone.constraints.new('COPY_TRANSFORMS')
    constraint = bone.constraints[-1]
    constraint.target = src
    constraint.subtarget = bone.name

You need to change the first two statements after the import to whatever code you need to select the two armatures. I tested with two armatures that had obvious names.

I didn't set the Mix, Target Space, Owner Space, or influence, assuming the defaults were what you wanted. They are the following fields mix_mode, target_space, owner_space, and influence.

mix mode can take any value in this list: 'REPLACE', 'BEFORE_FULL', 'BEFORE', 'BEFORE_SPLIT', 'AFTER_FULL', 'AFTER', 'AFTER_SPLIT'.

The spaces can take any value in this list: 'WORLD', 'CUSTOM', 'POSE', 'LOCAL_WITH_PARENT', 'LOCAL', 'LOCAL_OWNER_ORIENT'

Influence is a floating point number in the range of 0.0 to 1.0

You can find out more about the meaning of the values in the Copy Transforms Constraint manual page.

$\endgroup$
4
  • $\begingroup$ I've added a link to a demo file, if you have the time to show how the script works on the demo file. That would be much appreciated. I'm new to scripting with little knowledge but tryin to learn. $\endgroup$
    – Andrew
    Commented May 3, 2022 at 21:42
  • $\begingroup$ @Andrew, in your demo file, remove the text in the text editor and paste my text in. in line 3 change the text string near the end ('src') to 'Rig_1'. In line 4 change the string ('dst') to 'Rig_2'. Type ALT-P to run the script. $\endgroup$ Commented May 4, 2022 at 0:11
  • $\begingroup$ Dude you are the best. oh damn, I am greatly thankful. thank you very much. $\endgroup$
    – Andrew
    Commented May 4, 2022 at 20:18
  • $\begingroup$ @Andrew You're very welcome. Glad I could help. Good luck with your Python. $\endgroup$ Commented May 4, 2022 at 23:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .