Skip to content

Commit

Permalink
Added __repr__ for relationships classes.
Browse files Browse the repository at this point in the history
Added hierarchy_id flag for registration.
  • Loading branch information
AndresMWeber committed Mar 9, 2018
1 parent 191184a commit 43a30ed
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
3 changes: 3 additions & 0 deletions anvil/grouping/relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def __add__(self, other):
def __str__(self):
return str(self.set)

def __repr__(self):
return super(NodeRelationshipSet, self).__repr__().replace('>', '(children=%d)>' % (len(self)))

def append(self, node):
raise NotImplementedError

Expand Down
2 changes: 1 addition & 1 deletion anvil/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def wrapper(abstract_grouping, *args, **kwargs):
The top level key possibilities are: ['control', 'joint', 'node', 'set']
"""
skip_report = kwargs.pop('skip_report', False)
custom_hierarchy_ids = kwargs.pop('hierarchy_id', None)
custom_hierarchy_ids = kwargs.pop(cfg.ID_TYPE, None)
nodes_built = f(abstract_grouping, *args, **kwargs)

if skip_report:
Expand Down
3 changes: 0 additions & 3 deletions anvil/sub_rig_templates/base_sub_rig_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ def build_fk_chain(self, chain_start=None, chain_end=None, shape=None, duplicate
fk_controls = nt.NonLinearHierarchyNodeSet()
control_parent = parent.pop()
for node, shape in zip(fk_chain, to_size_list(shape or self.DEFAULT_FK_SHAPE, len(fk_chain))):
print('parenting fk control %s to %s' % (node, control_parent))

control = self.build_node(nt.Control,
reference_object=node,
shape=shape,
Expand All @@ -170,5 +168,4 @@ def build_fk_chain(self, chain_start=None, chain_end=None, shape=None, duplicate

control_parent = fk_controls[-1].node.connection_group
rt.dcc.connections.parent(control_parent, node, maintainOffset=True)
print(type(fk_chain))
return fk_chain, fk_controls
6 changes: 3 additions & 3 deletions anvil/sub_rig_templates/limb.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def build(self, parent=None, use_layout=True, build_ik=True, build_fk=True, meta
skip_register=True,
skip_report=True,
use_layout=use_layout, **self.build_kwargs)
self.register_node(ik_chain, 'ik_chain')
self.register_node(fk_chain, 'fk_chain')
self.register_node(blend_chain, 'blend_chain')
self.register_node(ik_chain, hierarchy_id='ik_chain')
self.register_node(fk_chain, hierarchy_id='fk_chain')
self.register_node(blend_chain, hierarchy_id='blend_chain')

self.rename()

Expand Down
2 changes: 1 addition & 1 deletion anvil/sub_rig_templates/spine.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def build(self, parent=None, meta_data=None, **kwargs):
parent=self.group_nodes,
meta_data=self.meta_data + {'name': 'spine', 'type': 'curve'},
degree=3)
self.register_node('curve_spine', spine_curve)
self.register_node('curve_spine', hierarchy_id=spine_curve)

self.rename()
self.LOG.info('Built sub rig %s' % self.__class__.__name__)
10 changes: 5 additions & 5 deletions tests/test_sub_rig.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_register_previously_created_with_name_tokens(self):
self.sub_rig = nt.SubRig()
self.sub_rig.build()
b = nt.Joint.build(name_tokens={'name': 'bob'})
self.sub_rig.register_node('test', b)
self.sub_rig.register_node('test', hierarchy_id=b)
# This test will override the previous name because it now should inherit the new sub rig tokens.
self.assertDictEqual(b.name_tokens,
{cfg.NAME: 'bob', cfg.SUB_RIG_TOKEN: cfg.SUB_RIG_TOKEN, cfg.TYPE: cfg.JOINT_TYPE})
Expand All @@ -60,7 +60,7 @@ def test_register_previously_created_with_name_tokens_overwrite(self):
self.sub_rig = nt.SubRig()
self.sub_rig.build()
b = nt.Joint.build(name_tokens={'name': 'silvia', cfg.SUB_RIG_TOKEN: 'muggle'})
self.sub_rig.register_node(b, 'test')
self.sub_rig.register_node(b, hierarchy_id='test')
self.assertDictEqual(b.name_tokens,
{'name': 'silvia',
cfg.SUB_RIG_TOKEN: 'muggle',
Expand All @@ -72,7 +72,7 @@ def test_register_previously_created_add_name_tokens(self):
self.sub_rig = nt.SubRig()
self.sub_rig.build()
b = nt.Joint.build(name_tokens={'name': 'silvia'})
self.sub_rig.register_node(b, 'test')
self.sub_rig.register_node(b, hierarchy_id='test')
self.assertDictEqual(b.name_tokens,
{'name': 'silvia',
cfg.SUB_RIG_TOKEN: cfg.SUB_RIG_TOKEN,
Expand Down Expand Up @@ -125,7 +125,7 @@ def test_register_previously_created_with_meta_data(self):
self.sub_rig = nt.SubRig()
self.sub_rig.build()
b = nt.Joint.build(meta_data={'name': 'bob'})
self.sub_rig.register_node('test', b)
self.sub_rig.register_node('test', hierarchy_id=b)
self.assertDictEqual(b.meta_data, {'name': 'bob', 'type': 'joint'})
self.assertDictEqual(b.name_tokens, {cfg.NAME: 'untitled', cfg.TYPE: cfg.JOINT_TYPE})

Expand All @@ -134,6 +134,6 @@ def test_register_previously_created_with_meta_data_overwrite(self):
self.sub_rig = nt.SubRig()
self.sub_rig.build()
b = nt.Joint.build(meta_data={'name': 'silvia'})
self.sub_rig.register_node('test', b)
self.sub_rig.register_node('test', hierarchy_id=b)
self.assertDictEqual(b.meta_data, {'name': 'silvia', cfg.SUB_RIG_TOKEN: cfg.SUB_RIG_TOKEN})
self.assertDictEqual(b.name_tokens, {cfg.NAME: 'untitled', cfg.TYPE: cfg.JOINT_TYPE})

0 comments on commit 43a30ed

Please sign in to comment.