def test_cbgroup_zero( self ): if env.appVersion( )[0] == 8.5: return self._runMessageTest( 'beforeNewCheck', lambda *args: self.cbgroup_zero(*args ), Scene.new )
def test_cbgroup_one(self): if env.appVersion()[0] == 8.5: return scenepath = get_maya_file("sphere.ma") triggerFunc = lambda: Scene.open(scenepath, force=1) self._runMessageTest("beforeOpenCheck", lambda *args: self.cbgroup_one(*args), triggerFunc)
def test_dagContainer(self): # only for maya 2011 and newer if env.appVersion()[0] < 2011: return # problem is that the dagContainer node is in fact a valid container # which must be compatible to the MFnContainerNode. It isnt though as # maya's hierarchy system only allows to derive from one parent, officially. # Internally it derives from containerBase and hence is compatible. # Just make sure it really is that way, as this is a special tweak. assert api.MFnContainerNode in nt.DagContainer.getMFnClasses()
def __init__(self): """Upon initialization, we will parse the currently loaded plugins and register them. Additionally we register our event to stay in the loop if anything changes.""" self.log = logging.getLogger('mrv.maya.nt.%s' % type(self).__name__) # yes, we need a string here, yes, its mel # UPDATE: In maya 2011, a method is alright ! melstr = 'python("import mrv.maya.nt; mrv.maya.nt.pluginDB.plugin_registry_changed()")' if env.appVersion()[0] < 2011.0: cmds.pluginInfo(changedCommand=melstr) else: # Okay, if we do this, maya crashes during shutdown, which is why we # use mel then ... nice work, Autodesk ;) # cmds.pluginInfo(changedCommand=self.plugin_registry_changed) mrvmaya.Mel.eval('pluginInfo -changedCommand "%s"' % melstr.replace('"', '\\"')) # END install callback self.plugin_registry_changed()
def test_data(self): # DATA CREATION ############### # create all implemented data types self.failUnlessRaises(TypeError, nt.Data.create) basic_types = [nt.VectorArrayData, nt.UInt64ArrayData, nt.StringData, nt.StringArrayData, nt.SphereData, nt.PointArrayData, nt.NObjectData, nt.MatrixData, nt.IntArrayData, nt.SubdData, nt.NurbsSurfaceData, nt.NurbsCurveData, nt.MeshData, nt.LatticeData, nt.DoubleArrayData, nt.ComponentListData, nt.ArrayAttrsData] if env.appVersion()[0] > 2010.0: basic_types.append(nt.NIdData) # END 2011 special handling knullobj = nt.api.MObject() for bt in basic_types: try: data = bt.create() except: print "Failed to create %r with MFn: %r" % (bt, bt._mfncls) raise # END exception handling for debugging assert data != knullobj assert isinstance(data, bt) # END for each type with a basic constructor # PLUGIN DATA # use storage node data type pd = nt.PluginData.create(PyPickleData.kPluginDataId) # NUMERIC DATA # these items cannot work or do not work as simple types are not represented # by data containers forbidden = ( 'kLast', 'kDouble', 'kInvalid', 'k4Double', 'kBoolean', 'kShort', 'kInt', 'kByte', 'kAddr', 'kChar', 'kLong', 'kFloat') types = [(k, v) for k,v in api.MFnNumericData.__dict__.iteritems() if k.startswith('k') and k not in forbidden] assert types for type_name, type_id in types: data = nt.NumericData.create(type_id) assert not data.isNull() and isinstance(data, nt.NumericData) # END for each numeric data type # COMPONENT LIST DATA ##################### # special testing mvc = nt.SingleIndexedComponent.create(api.MFn.kMeshVertComponent) cd = nt.ComponentListData.create() assert cd.length() == 0 assert mvc not in cd cd.add(mvc) assert len(cd) == 1 # ERROR: It says our component is NOT contained in the data list, although # we just added it and although it says the list has an item # assert cd.has(mvc) # assert mvc in cd assert not cd.has(mvc) # see above assert mvc not in cd # see above, we keep it to call the functions cd.remove(mvc) assert len(cd) == 0
def test_cbgroup_zero(self): if env.appVersion()[0] == 8.5: return self._runMessageTest('beforeNewCheck', lambda *args: self.cbgroup_zero(*args), Scene.new)
def test_data(self): # DATA CREATION ############### # create all implemented data types self.failUnlessRaises(TypeError, nt.Data.create) basic_types = [nt.VectorArrayData, nt.UInt64ArrayData, nt.StringData, nt.StringArrayData, nt.SphereData, nt.PointArrayData, nt.NObjectData, nt.MatrixData, nt.IntArrayData, nt.SubdData, nt.NurbsSurfaceData, nt.NurbsCurveData, nt.MeshData, nt.LatticeData, nt.DoubleArrayData, nt.ComponentListData, nt.ArrayAttrsData ] if env.appVersion()[0] > 2010.0: basic_types.append(nt.NIdData) # END 2011 special handling knullobj = nt.api.MObject() for bt in basic_types: try: data = bt.create() except: print "Failed to create %r with MFn: %r" % (bt, bt._mfncls) raise # END exception handling for debugging assert data != knullobj assert isinstance(data, bt) # END for each type with a basic constructor # PLUGIN DATA # use storage node data type pd = nt.PluginData.create(PyPickleData.kPluginDataId) # NUMERIC DATA # these items cannot work or do not work as simple types are not represented # by data containers forbidden = ( 'kLast', 'kDouble', 'kInvalid', 'k4Double', 'kBoolean', 'kShort', 'kInt', 'kByte', 'kAddr', 'kChar', 'kLong', 'kFloat' ) types = [ (k, v) for k,v in api.MFnNumericData.__dict__.iteritems() if k.startswith('k') and k not in forbidden ] assert types for type_name, type_id in types: data = nt.NumericData.create(type_id) assert not data.isNull() and isinstance(data, nt.NumericData) # END for each numeric data type # COMPONENT LIST DATA ##################### # special testing mvc = nt.SingleIndexedComponent.create(api.MFn.kMeshVertComponent) cd = nt.ComponentListData.create() assert cd.length() == 0 assert mvc not in cd cd.add(mvc) assert len(cd) == 1 # ERROR: It says our component is NOT contained in the data list, although # we just added it and although it says the list has an item # assert cd.has(mvc) # assert mvc in cd assert not cd.has(mvc) # see above assert mvc not in cd # see above, we keep it to call the functions cd.remove(mvc) assert len(cd) == 0