Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Vegdahl <cessen@cessen.com>2011-06-22 06:06:16 +0400
committerNathan Vegdahl <cessen@cessen.com>2011-06-22 06:06:16 +0400
commit72e2f73b37ab33a09345dec21035c46bd8c7f898 (patch)
tree2e6dccd3c40410c82c8bf4110a53e44d9a48a01d /rigify/generate.py
parent3dbeaddc3cef7f1acc648b26000d12f517794ddf (diff)
Rigify: constraints are now copied over from metarig.
This allows advanced users to do certain limited custom rigging work in the metarig, and have it transfer to the generated rig. Custom properties are also copied when using the copy_bone function in utils. TODO: transfer drivers from the metarig as well.
Diffstat (limited to 'rigify/generate.py')
-rw-r--r--rigify/generate.py39
1 files changed, 31 insertions, 8 deletions
diff --git a/rigify/generate.py b/rigify/generate.py
index 96a6d68d..73552442 100644
--- a/rigify/generate.py
+++ b/rigify/generate.py
@@ -130,6 +130,15 @@ def generate_rig(context, metarig):
obj.select = True
scene.objects.active = obj
+ # Copy over bone properties
+ for bone in metarig.data.bones:
+ bone_gen = obj.data.bones[bone.name]
+
+ # B-bone stuff
+ bone_gen.bbone_segments = bone.bbone_segments
+ bone_gen.bbone_in = bone.bbone_in
+ bone_gen.bbone_out = bone.bbone_out
+
# Copy over the pose_bone properties
for bone in metarig.pose.bones:
bone_gen = obj.pose.bones[bone.name]
@@ -146,14 +155,28 @@ def generate_rig(context, metarig):
for prop in bone.keys():
bone_gen[prop] = bone[prop]
- # Copy over bone properties
- for bone in metarig.data.bones:
- bone_gen = obj.data.bones[bone.name]
-
- # B-bone stuff
- bone_gen.bbone_segments = bone.bbone_segments
- bone_gen.bbone_in = bone.bbone_in
- bone_gen.bbone_out = bone.bbone_out
+ # Constraints
+ for con1 in bone.constraints:
+ con2 = bone_gen.constraints.new(type=con1.type)
+
+ # Copy attributes
+ keys = dir(con1)
+ for key in keys:
+ if not key.startswith("_") \
+ and not key.startswith("error_") \
+ and key != "is_valid" \
+ and key != "rna_type" \
+ and key != "type" \
+ and key != "bl_rna":
+ try:
+ setattr(con2, key, getattr(con1, key))
+ except AttributeError:
+ print("Could not write to constraint attribute '%s'" % key)
+
+ # Set metarig target to rig target
+ if "target" in keys:
+ if getattr(con2, "target") == metarig:
+ setattr(con2, "target", obj)
t.tick("Duplicate rig: ")
#----------------------------------