Anim: make RNA property bone_collection.parent writable
Moving a bone collection to another parent is now possible in Python by assigning to `bone_collection.parent`. Thanks to Sergey for the implementation.
This commit is contained in:
@@ -111,6 +111,37 @@ class BoneCollectionTest(unittest.TestCase):
|
||||
# Check the array order.
|
||||
self.assertEqual([root1, r1_child1, root2, r1_child1_001, r2_child1, r2_child2], list(bcolls.all))
|
||||
|
||||
def test_parent_property(self):
|
||||
# Just to keep the rest of the code shorter.
|
||||
bcolls = self.arm.collections
|
||||
|
||||
self.assertEqual([], list(bcolls), "By default an Armature should have no collections")
|
||||
|
||||
# Build a hierarchy.
|
||||
root1 = bcolls.new('root1')
|
||||
r1_child1 = bcolls.new('r1_child1', parent=root1)
|
||||
r1_child2 = bcolls.new('r1_child2', parent=root1)
|
||||
root2 = bcolls.new('root2')
|
||||
r2_child1 = bcolls.new('r2_child1', parent=root2)
|
||||
r2_child2 = bcolls.new('r2_child2', parent=root2)
|
||||
|
||||
# Check getting the parent.
|
||||
self.assertEqual(root1, r1_child1.parent)
|
||||
self.assertEqual(root1, r1_child2.parent)
|
||||
self.assertEqual(root2, r2_child1.parent)
|
||||
self.assertEqual(root2, r2_child2.parent)
|
||||
|
||||
# Move r1_child1 to be a child of root2 by assigning the parent.
|
||||
r1_child1.parent = root2
|
||||
self.assertEqual(root2, r1_child1.parent)
|
||||
|
||||
# Check the sibling order.
|
||||
self.assertEqual([r2_child1, r2_child2, r1_child1], list(root2.children))
|
||||
|
||||
# Make r1_child1 a root.
|
||||
r1_child1.parent = None
|
||||
self.assertIsNone(r1_child1.parent)
|
||||
|
||||
def test_bone_collection_bones(self):
|
||||
# Build a hierarchy on the armature.
|
||||
bcolls = self.arm.collections
|
||||
|
||||
Reference in New Issue
Block a user