Пример #1
0
    def setUp(self):
        ''' Called initially to set up the Maya test environment '''
        # Load plugins
        self.assertTrue(self.pluginsLoaded)

        # Open ballset.ma scene in testSamples
        mayaUtils.openGroupBallsScene()

        # Clear selection to start off
        cmds.select(clear=True)
Пример #2
0
    def testProxyShapeFilteredChildren(self):
        mayaUtils.openGroupBallsScene()
        cmds.select(clear=True)

        # Check that the proxy shape has a single child, Ball_set.
        psPath = ufe.PathString.path('|transform1|proxyShape1')
        psItem = ufe.Hierarchy.createItem(psPath)
        psHier = ufe.Hierarchy.hierarchy(psItem)
        psChildren = psHier.children()
        self.assertEqual(len(psChildren), 1)

        # Verify that the single child is the Ball_set.
        ballSetPathStr = '|transform1|proxyShape1,/Ball_set'
        ballSetPath = ufe.PathString.path(ballSetPathStr)
        ballSetItem = ufe.Hierarchy.createItem(ballSetPath)
        self.assertEqual(ballSetItem, psChildren[0])

        # Inactivate Ball_set.
        ballSetPrim = mayaUsd.ufe.ufePathToPrim(ballSetPathStr)
        ballSetPrim.SetActive(False)

        # Proxy shape should now have no children.
        children = psHier.children()
        self.assertEqual(0, len(children))
        self.assertNotIn(ballSetItem, children)

        # Get the child filter for the hierarcy handler corresponding
        # to the runtime of the ProxyShape.
        # Because the proxy shape hierarchy handler overrides the
        # Maya child filter and returns the same child filter.
        usdHierHndlr = ufe.RunTimeMgr.instance().hierarchyHandler(
            psItem.runTimeId())
        cf = usdHierHndlr.childFilter()

        # Toggle the "Inactive Prims" on and get the filtered children
        # (with inactive prims) and verify Ball_set is one of them.
        cf[0].value = True
        children = psHier.filteredChildren(cf)
        self.assertEqual(1, len(children))
        self.assertIn(ballSetItem, children)
Пример #3
0
    def testFilteredChildren(self):
        mayaUtils.openGroupBallsScene()
        cmds.select(clear=True)

        # Check that we have six balls
        propsPath = ufe.PathString.path(
            '|transform1|proxyShape1,/Ball_set/Props')
        propsItem = ufe.Hierarchy.createItem(propsPath)
        propsHier = ufe.Hierarchy.hierarchy(propsItem)
        self.assertEqual(6, len(propsHier.children()))

        # Deactivate Ball_3 (which will remove it from children)
        ball3PathStr = '|transform1|proxyShape1,/Ball_set/Props/Ball_3'
        ball3Path = ufe.PathString.path(ball3PathStr)
        ball3Item = ufe.Hierarchy.createItem(ball3Path)

        # Set Ball_3 to inactive.
        ball3Prim = mayaUsd.ufe.ufePathToPrim(ball3PathStr)
        ball3Prim.SetActive(False)

        # Props should now have 5 children and ball3 should not be one of them.
        children = propsHier.children()
        self.assertEqual(5, len(children))
        self.assertNotIn(ball3Item, children)

        # Get the child filter for the hierarchy handler corresponding
        # to the runtime of the Ball_3.
        usdHierHndlr = ufe.RunTimeMgr.instance().hierarchyHandler(
            ball3Item.runTimeId())
        cf = usdHierHndlr.childFilter()

        # Toggle "Inactive Prims" on and get the filtered children
        # (with inactive prims) and verify ball3 is one of them.
        cf[0].value = True
        children = propsHier.filteredChildren(cf)
        self.assertEqual(6, len(children))
        self.assertIn(ball3Item, children)