def test_MPlugAccess_nodeDeleted(self): attr = Attribute(MayaTest.SCENE['transform_1_attr_1']) attr.MPlug mc.delete(MayaTest.SCENE['transform_1']) with self.assertRaises(InvalidMayaObjectError): attr.MPlug mc.undo() attr.MPlug mc.redo() with self.assertRaises(InvalidMayaObjectError): attr.MPlug mc.undo() attr.MPlug
def test_MPlugAccess_attributeDeleted(self): transform = MayaTest.SCENE['transform_1'] attrName = 'myTestAttr' mc.addAttr(transform, ln=attrName, min=-1, max=1, dv=0.5) fullAttrName = '{}.{}'.format(transform, attrName) attr = Attribute(fullAttrName) attr.MPlug mc.deleteAttr(fullAttrName) with self.assertRaises(InvalidMayaObjectError): attr.MPlug mc.undo() attr.MPlug mc.redo() with self.assertRaises(InvalidMayaObjectError): attr.MPlug mc.undo() attr.MPlug
from mapya import utils reload(utils) utils.reload_all() from mapya.nodeType.transform import Transform tra1 = Transform('pSphere1') tra2 = Transform('pSphere2') print(tra1.matrix) tra1.matrix = tra2.matrix # ###################### # Attribute # ###################### from mapya import utils reload(utils) utils.reload_all() from mapya.attribute import Attribute attr1 = Attribute('pSphere1.tx') attr2 = Attribute('pSphere2.ty') print(dir(attr1)) print(help(attr1)) print(attr1) print(attr1.get()) print(attr1.set(1.5)) print(attr1.MObject) print(attr1 + attr2) print(attr1 - attr2) print(attr1 * attr2) print(attr1 / attr2) print(attr1 == attr2) print(attr1 != attr2) attr1.connect(attr2) attr1.disconnect(attr2)
def __getattribute__(self, attrName): return Attribute(object.__getattribute__(self, '__node__'), attrName)
def test_connect_disconnect_inputs_outputs(self): driver_node = MayaTest.SCENE['transform_1'] driven_node = MayaTest.SCENE['transform_2'] for attr in ['tx', 'r', 'scale']: driver_attr = '{0}.{1}'.format(driver_node, attr) driven_attr = '{0}.{1}'.format(driven_node, attr) driver_instance = Attribute(driver_attr) driven_instance = Attribute(driven_attr) driver_instance.connect(driven_instance) driven_input = mc.listConnections(driven_attr, plugs=True)[0] self.assertEqual(driven_instance.inputs(), [driven_input]) self.assertEqual(driven_instance.input(), driven_input) self.assertEqual(driven_instance.outputs(), []) self.assertEqual(driven_instance.output(), None) driver_output = mc.listConnections(driver_attr, plugs=True)[0] self.assertEqual(driver_instance.inputs(), []) self.assertEqual(driver_instance.input(), None) self.assertEqual(driver_instance.outputs(), [driver_output]) self.assertEqual(driver_instance.output(), driver_output) driver_instance.disconnect(driven_instance) self.assertEqual(driven_instance.input(), None)
def test_instantiation(self): for attr_name in get_scene_attributes(): attr_instance = Attribute(attr_name) self.assertEqual(str(attr_instance), attr_name)
def test_MPlugAccess(self): attr = Attribute(MayaTest.SCENE['transform_1_attr_1']) attr.MPlug
def get_scene_attribute_instances(**get_attributes_kwargs): return [ Attribute(a) for a in get_scene_attributes(**get_attributes_kwargs) ]