Esempio n. 1
0
    def test_instancesAndParenting(self):
        mrvmaya.Scene.open(get_maya_file("instancetest.ma"), force=True)
        m = nt.Node("m")            # mesh, two direct and two indirect instances
        c1 = nt.createNode("|c1", "transform")

        assert m.instanceCount(0) == 2 
        assert m.instanceCount(1) == 4 

        # test parenting
        mci = c1.addInstancedChild(m)

        assert m.instanceCount(0) == 3 
        assert m.instanceCount(1) == 5  # direct + indirect

        c1.removeChild(mci)

        assert m.instanceCount(0) == 2 
        assert m.instanceCount(1) == 4  # direct + indirect

        # check reparent
        d1 = nt.createNode("|d1", "transform")
        c1 = c1.reparent(d1)

        assert m.instanceCount(0) == 2 
        assert m.instanceCount(1) == 4 

        # reparent an instanced transform under d1
        a2 = nt.Node("a2")

        a2 = a2.reparent(d1, raiseOnInstance=0)         # destroys instances
        assert m.instanceCount(0) == 2 
        assert m.instanceCount(1) == 2 
Esempio n. 2
0
	def test_instancesAndParenting( self ):
		mrvmaya.Scene.open( get_maya_file( "instancetest.ma" ), force=True )
		m = nt.Node( "m" )			# mesh, two direct and two indirect instances
		c1 = nt.createNode( "|c1", "transform" )

		assert m.instanceCount( 0 ) == 2 
		assert m.instanceCount( 1 ) == 4 

		# test parenting
		mci = c1.addInstancedChild( m )

		assert m.instanceCount( 0 ) == 3 
		assert m.instanceCount( 1 ) == 5 	# direct + indirect

		c1.removeChild( mci )

		assert m.instanceCount( 0 ) == 2 
		assert m.instanceCount( 1 ) == 4 	# direct + indirect

		# check reparent
		d1 = nt.createNode( "|d1", "transform" )
		c1 = c1.reparent( d1 )

		assert m.instanceCount( 0 ) == 2 
		assert m.instanceCount( 1 ) == 4 

		# reparent an instanced transform under d1
		a2 = nt.Node( "a2" )

		a2 = a2.reparent( d1, raiseOnInstance=0 )			# destroys instances
		assert m.instanceCount( 0 ) == 2 
		assert m.instanceCount( 1 ) == 2 
Esempio n. 3
0
 def test_plugin_handling(self):
     mrp = "Mayatomr"
     pp = 'persistence'
     assert not cmds.pluginInfo(mrp, q=1, loaded=1)
     
     assert not hasattr(nt, 'Transmat')
     cmds.loadPlugin(mrp)
     
     # loading a plugin will add the node types
     assert hasattr(nt, 'Transmat')
     assert nt.typ.nodeTypeTree.has_node('transmat')
     tmat = nt.Transmat()    # mr dep node
     tmat.delete()
     
     dll = nt.MapVizShape()  # mr dag node
     assert isinstance(dll, nt.DagNode)
     dll.delete()
     cmds.flushUndo()    # make sure we get rid of the custom data
     
     
     # custom node types are favored and not overwritten by dummies when 
     # loading
     assert nt.StorageNode is mstorage.StorageNode
     
     # custom node types will remain when unloaded
     cmds.unloadPlugin(pp)
     assert not cmds.pluginInfo(pp, q=1, loaded=1) 
     assert hasattr(nt, 'StorageNode')
     
     # unloading a plugin will remove the nodetypes as well as the hierarchy 
     # entries
     # NOTE: on OSX unloading the plugin beautifully crashes maya, probably
     # a memory exception as MR claims to have had a peak memory of 136 GB
     # As a final goal, this test should be fixed to run here, there 
     # probably is some kind of workaround.
     # http://tracking.byronimo.de/view.php?id=144
     mr_testobj = "contour_composite1"
     if sys.platform != 'darwin':
         cmds.unloadPlugin(mrp, force=1)
         
         assert not hasattr(nt, 'Transmat')
         assert not hasattr(nt, 'MapVizShape')
         assert not nt.typ.nodeTypeTree.has_node('transmat')
         assert not nt.typ.nodeTypeTree.has_node('mapVizShape')
     
 
         # plugins required by a scene trigger the database to update as well
         assert not cmds.pluginInfo(mrp, q=1, loaded=1)
         assert not nt.objExists('transmat1')
         needs_mr_scene = get_maya_file('needsMayatomr.ma')
         mrvmaya.Scene.open(needs_mr_scene, force=True)
         assert hasattr(nt, 'Transmat')
         assert not nt.objExists(mr_testobj), "object shouldn't exist if it works"
         
         # try it during reference and import scenarios
         mrvmaya.Scene.new(force=True)
         cmds.unloadPlugin(mrp, force=0)
         assert not hasattr(nt, 'Transmat')
         
         FileReference.create(needs_mr_scene)
         assert hasattr(nt, 'Transmat'), "Should have triggered the callback"
         assert not nt.objExists(mr_testobj), "object shouldn't exist if it works"
         
         # try import
         mrvmaya.Scene.new(force=True)
         cmds.unloadPlugin(mrp, force=0)
         assert not hasattr(nt, 'Transmat')
         
         
         cmds.file(needs_mr_scene, i=True)
         assert hasattr(nt, 'Transmat'), "Should have triggered callback by import"
         assert not nt.objExists(mr_testobj), "object shouldn't exist if it works"
     # END skip this on osx
     
     assert not nt.objExists(mr_testobj)
     cmds.undoInfo(st=0)
     mod = api.MDGModifier()
     mod.createNode('transmat')
     assert not nt.objExists(mr_testobj), "Shouldn't actually create the object even if undo is off"
     cmds.undoInfo(st=1)
     
     # dynamically added types (which will not trigger a plugin changed event)
     # can be wrapped as well
     customMI = get_maya_file('customshader.mi')
     csn = "testCustomShader"
     csnc = "TestCustomShader"
     mrvmaya.Mel.mrFactory('-load',customMI)
     
     # it doesnt exist, but can be wrapped nontheless, then it exists
     assert not hasattr(nt, csnc)
     cs = nt.Node(cmds.createNode(csn))
     assert hasattr(nt, csnc)
Esempio n. 4
0
	def test_plugin_handling(self):
		mrp = "Mayatomr"
		pp = 'persistence'
		assert not cmds.pluginInfo(mrp, q=1, loaded=1)
		
		assert not hasattr(nt, 'Transmat')
		cmds.loadPlugin(mrp)
		
		# loading a plugin will add the node types
		assert hasattr(nt, 'Transmat')
		assert nt.typ.nodeTypeTree.has_node('transmat')
		tmat = nt.Transmat()	# mr dep node
		tmat.delete()
		
		dll = nt.MapVizShape()	# mr dag node
		assert isinstance(dll, nt.DagNode)
		dll.delete()
		cmds.flushUndo()	# make sure we get rid of the custom data
		
		
		# custom node types are favored and not overwritten by dummies when 
		# loading
		assert nt.StorageNode is mstorage.StorageNode
		
		# custom node types will remain when unloaded
		cmds.unloadPlugin(pp)
		assert not cmds.pluginInfo(pp, q=1, loaded=1) 
		assert hasattr(nt, 'StorageNode')
		
		# unloading a plugin will remove the nodetypes as well as the hierarchy 
		# entries
		# NOTE: on OSX unloading the plugin beautifully crashes maya, probably
		# a memory exception as MR claims to have had a peak memory of 136 GB
		# As a final goal, this test should be fixed to run here, there 
		# probably is some kind of workaround.
		# http://tracking.byronimo.de/view.php?id=144
		if sys.platform != 'darwin':
			cmds.unloadPlugin(mrp, force=1)
			
			assert not hasattr(nt, 'Transmat')
			assert not hasattr(nt, 'MapVizShape')
			assert not nt.typ.nodeTypeTree.has_node('transmat')
			assert not nt.typ.nodeTypeTree.has_node('mapVizShape')
		
	
			# plugins required by a scene trigger the database to update as well
			assert not cmds.pluginInfo(mrp, q=1, loaded=1)
			mrvmaya.Scene.open(get_maya_file('needsMayatomr.ma'), force=True)
			assert hasattr(nt, 'Transmat')
		# END skip this on osx 
		
		# dynamically added types ( which will not trigger a plugin changed event )
		# can be wrapped as well
		customMI = get_maya_file('customshader.mi')
		csn = "testCustomShader"
		csnc = "TestCustomShader"
		mrvmaya.Mel.mrFactory('-load',customMI)
		
		# it doesnt exist, but can be wrapped nontheless, then it exists
		assert not hasattr(nt, csnc)
		cs = nt.Node(cmds.createNode(csn))
		assert hasattr(nt, csnc)