Last active
April 6, 2017 20:59
-
-
Save AndresMWeber/fb0e9b2e8e4dd548c3b3173da94945dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MayaElement(AbstractElement): | |
def __init__(self, | |
group_top='', | |
group_model='', | |
group_joint='', | |
group_nodes='', | |
group_world='', | |
parent='', | |
scale=1.0, | |
**kwargs): | |
self.hierarchy = [] | |
self.joints = [] | |
self.controls = [] | |
self.nom = nomenclate.Nom(**kwargs) | |
self.scale = scale | |
print 'collecting nodes.', group_top, group_model, group_joint, group_nodes, group_world | |
self.top_group = MayaNodeFactory.MayaTransform.factory(group_top) | |
self.group_model = MayaNodeFactory.MayaTransform.factory(group_model) | |
self.group_joint = MayaNodeFactory.MayaTransform.factory(group_joint) | |
self.group_nodes = MayaNodeFactory.MayaTransform.factory(group_nodes) | |
self.group_world = MayaNodeFactory.MayaTransform.factory(group_world) | |
print 'done collecting nodes' | |
self.register_nodes([self.top_group, self.group_model, self.group_joint, self.group_nodes, self.group_world], | |
node_type='hierarchy') | |
self.SERIALIZABLE.append('scale') | |
self.parent(parent) | |
print 'serialized: ', self.serialize() | |
self.setup_connections() | |
self.imprint_serialization() | |
@classmethod | |
def create(cls, **kwargs): | |
kwargs['name'] = kwargs.get('name', DEFAULT_ELEMENT_NAME) | |
nom = nomenclate.Nom(**kwargs) | |
group_top = MayaNodeFactory.MayaTransform.create(**nom.state) | |
group_model = MayaNodeFactory.MayaTransform.create(parent=group_top, **nom.state) | |
group_joint = MayaNodeFactory.MayaTransform.create(parent=group_top, **nom.state) | |
group_nodes = MayaNodeFactory.MayaTransform.create(parent=group_top, **nom.state) | |
group_world = MayaNodeFactory.MayaTransform.create(parent=group_top, **nom.state) | |
group_world.set_attr('inheritsTransform', 0) | |
print 'currently trying to instantiate a: ', cls | |
element_instance = cls( | |
group_top=group_top, | |
group_model=group_model, | |
group_joint=group_joint, | |
group_nodes=group_nodes, | |
group_world=group_world, | |
**nom.state) | |
element_instance.rename(**nom.state) | |
#element_instance._create_joints() | |
#element_instance._create_controls() | |
return element_instance | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error | |
Traceback (most recent call last): | |
File "C:\Users\andre\Documents\maya\libmayapy\unittest\case.py", line 329, in run | |
testMethod() | |
File "C:\Users\andre\dev\awkomodo\rigger\tests\testRigLib\testCore\testElements\test_universal.py", line 65, in test_creation | |
universal = MayaNodeFactory.Universal.create(name='name', side='left') | |
File "C:\Users\andre\dev\awkomodo\rigger\rig_lib\core\elements\universal.py", line 45, in create | |
element_instance = super(Universal, cls).create(*args, **kwargs) | |
File "C:\Users\andre\dev\awkomodo\rigger\rig_lib\core\nodes\maya\element.py", line 95, in create | |
**nom.state) | |
File "C:\Users\andre\dev\awkomodo\rigger\rig_lib\core\elements\universal.py", line 40, in __init__ | |
self.control_global_A = Control.factory(control_global_A) | |
File "C:\Users\andre\dev\awkomodo\rigger\rig_lib\core\nodes\maya\transform.py", line 62, in factory | |
return cls(node_reference, *args, **kwargs) | |
File "C:\Users\andre\dev\awkomodo\rigger\rig_lib\core\nodes\maya\control.py", line 32, in __init__ | |
super(MayaControl, self).__init__(maya_transform, **kwargs) | |
File "C:\Users\andre\dev\awkomodo\rigger\rig_lib\core\nodes\maya\transform.py", line 25, in __init__ | |
self._node_wrapper = MayaNode(node, *args, **kwargs) | |
File "C:\Users\andre\dev\awkomodo\rigger\rig_lib\core\nodes\maya\node.py", line 27, in __init__ | |
self._dag_path = self.get_dag_node(node) | |
File "C:\Users\andre\dev\awkomodo\rigger\rig_lib\core\nodes\maya\node.py", line 196, in get_dag_node | |
selection_list.add(maya_transform) | |
RuntimeError: (kInvalidParameter): Object does not exist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Universal(Element): | |
def __init__(self, | |
name='universal', | |
group_top='', | |
group_model='', | |
group_joint='', | |
group_nodes='', | |
group_world='', | |
control_global_A='', | |
control_global_B='', | |
parent='', | |
scale=1.0, | |
**kwargs): | |
super(Universal, self).__init__( | |
group_top=group_top, | |
group_model=group_model, | |
group_joint=group_joint, | |
group_nodes=group_nodes, | |
group_world=group_world, | |
parent=parent, | |
scale=scale, | |
**kwargs) | |
print "PASSED CONTROLS: ", control_global_A, control_global_B | |
self.control_global_A = Control.factory(control_global_A) | |
self.control_global_B = Control.factory(control_global_B) | |
@classmethod | |
def create(cls, **kwargs): | |
element_instance = super(Universal, cls).create(**kwargs) | |
element_instance.nom.childtype = 'universalA' | |
element_instance.control_global_A = Control.create( | |
parent=element_instance.group_top, | |
**element_instance.nom.state) | |
element_instance.nom.childtype = 'universalB' | |
element_instance.control_global_B = Control.create( | |
parent=element_instance.control_global_A.group_connection, | |
**element_instance.nom.state) | |
return element_instance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment