def testBasisCurves(self):
        self._StartTest('basisCurves')

        cmds.move(20, -10, 10, 'persp')
        cmds.rotate(60, 0, 30, 'persp')
        cmds.modelEditor('modelPanel4', edit=True, grid=False)

        selection = ufe.Selection()
        selection.append(
            self._GetSceneItem('|stage|stageShape',
                               '/Linear/Tubes/VaryingWidth'))
        selection.append(
            self._GetSceneItem('|stage|stageShape',
                               '/Linear/Ribbons/VaryingWidth'))
        selection.append(
            self._GetSceneItem('|stage|stageShape',
                               '/Cubic/Tubes/VaryingWidth'))
        selection.append(
            self._GetSceneItem('|stage|stageShape',
                               '/Cubic/Ribbons/VaryingWidth'))

        self._RunTest(0, selection)
        self._RunTest(1, selection)
        self._RunTest(2, selection)
        self._RunTest(3, selection)
示例#2
0
 def selectCmd(item):
     if item.runTimeId() == 1:
         # Single path segment.  Simply pop the |world head of path.
         p = str(item.path().popHead())
         cmds.select(p)
     else:
         sn = ufe.Selection()
         sn.append(item)
         ufeSelectCmd.replaceWith(sn)
示例#3
0
def selectUfeItems(selectItems):
    """
    Add given UFE item or list of items to a UFE global selection list
    """
    ufeSelectionList = ufe.Selection()
    
    realListToSelect = selectItems if type(selectItems) is list else [selectItems]
    for item in realListToSelect:
        ufeSelectionList.append(item)
    
    ufe.GlobalSelection.get().replaceWith(ufeSelectionList)
    def _RunTest(self):
        globalSelection = ufe.GlobalSelection.get()
        globalSelection.clear()
        self.assertSnapshotClose('%s_unselected.png' % self._testName)

        # Select one instance.
        sceneItem = self._GetSceneItem(0)
        globalSelection.append(sceneItem)
        self.assertSnapshotClose('%s_select_one.png' % self._testName)
        globalSelection.clear()

        # We'll populate a new selection and swap that into the global
        # selection to minimize the overhead of modifying the global selection
        # one item at a time.
        newSelection = ufe.Selection()

        # Select the first seven instances. The most recently selected item
        # should get "Lead" highlighting.
        for instanceIndex in range(7):
            sceneItem = self._GetSceneItem(instanceIndex)
            newSelection.append(sceneItem)
        globalSelection.replaceWith(newSelection)
        self.assertSnapshotClose('%s_select_seven.png' % self._testName)
        globalSelection.clear()
        newSelection.clear()

        # Select the back half of the instances.
        for instanceIndex in range(self._numInstances // 2,
                                   self._numInstances):
            sceneItem = self._GetSceneItem(instanceIndex)
            newSelection.append(sceneItem)
        globalSelection.replaceWith(newSelection)
        self.assertSnapshotClose('%s_select_half.png' % self._testName)
        globalSelection.clear()
        newSelection.clear()

        # Select all instances
        for instanceIndex in range(self._numInstances):
            sceneItem = self._GetSceneItem(instanceIndex)
            newSelection.append(sceneItem)
        globalSelection.replaceWith(newSelection)
        self.assertSnapshotClose('%s_select_all.png' % self._testName)
        globalSelection.clear()
        newSelection.clear()

        # Select the PointInstancer itself
        sceneItem = self._GetSceneItem()
        globalSelection.append(sceneItem)
        self.assertSnapshotClose('%s_select_PointInstancer.png' %
                                 self._testName)
        globalSelection.clear()
示例#5
0
def selectPath(path, replace=False):
    """ 
        Select a path in the UFE Global selection
        Args:
            path (ufe.Path): The UFE path to select
            replace (bool=False): Replace the selection with
                                    given UFE path
    """
    sceneItem = ufe.Hierarchy.createItem(path)
    if replace:
        selection = ufe.Selection()
        selection.append(sceneItem)
        ufeSelectCmd.replaceWith(selection)
    else:
        ufeSelectCmd.append(sceneItem)
    def testExportedNURBS(self):
        self._StartTest('nurbsCircleExport')

        cmds.move(6, -6, 6, 'persp')
        cmds.rotate(60, 0, 45, 'persp')
        cmds.modelEditor('modelPanel4', edit=True, grid=False)

        selection = ufe.Selection()
        selection.append(
            self._GetSceneItem('|stage|stageShape', '/nurbsCircle1'))

        self._RunTest(0, selection)
        self._RunTest(1, selection)
        self._RunTest(2, selection)
        self._RunTest(3, selection)
示例#7
0
def selectPath(path, replace=False):
    """ 
        Select a path in the UFE Global selection
        Args:
            path (ufe.Path): The UFE path to select
            replace (bool=False): Replace the selection with
                                    given UFE path
    """
    # Do this import inside this function rather than at the top of the file
    # so that the module can be imported and ufeFeatureSetVersion() can be
    # called prior to maya.standalone.initialize().
    try:
        from maya.internal.ufeSupport import ufeSelectCmd
    except ImportError:
        # Maya 2019 and 2020 don't have ufeSupport plugin, so use fallback.
        from ufeScripts import ufeSelectCmd

    sceneItem = ufe.Hierarchy.createItem(path)
    if replace:
        selection = ufe.Selection()
        selection.append(sceneItem)
        ufeSelectCmd.replaceWith(selection)
    else:
        ufeSelectCmd.append(sceneItem)
示例#8
0
 def selectCmd(item):
     sn = ufe.Selection()
     sn.append(item)
     ufeSelectCmd.replaceWith(sn)
    def testUsdGroup(self):
        '''Creation of USD group objects.'''

        mayaPathSegment = mayaUtils.createUfePathSegment(
            "|world|transform1|proxyShape1")

        usdSegmentBall5 = usdUtils.createUfePathSegment(
            "/Ball_set/Props/Ball_5")
        ball5Path = ufe.Path([mayaPathSegment, usdSegmentBall5])
        ball5Item = ufe.Hierarchy.createItem(ball5Path)

        usdSegmentBall3 = usdUtils.createUfePathSegment(
            "/Ball_set/Props/Ball_3")
        ball3Path = ufe.Path([mayaPathSegment, usdSegmentBall3])
        ball3Item = ufe.Hierarchy.createItem(ball3Path)

        usdSegmentProps = usdUtils.createUfePathSegment("/Ball_set/Props")
        parentPath = ufe.Path([mayaPathSegment, usdSegmentProps])
        parentItem = ufe.Hierarchy.createItem(parentPath)

        parentHierarchy = ufe.Hierarchy.hierarchy(parentItem)
        parentChildrenPre = parentHierarchy.children()
        self.assertEqual(len(parentChildrenPre), 6)

        newGroupName = ufe.PathComponent("newGroup")

        # get the USD stage
        stage = mayaUsd.ufe.getStage(str(mayaPathSegment))

        # set the edit target to balls.usda
        layer = stage.GetLayerStack()[1]
        self.assertEqual("ballset.usda", layer.GetDisplayName())
        stage.SetEditTarget(layer)

        ufeSelectionList = ufe.Selection()
        ufeSelectionList.append(ball5Item)
        ufeSelectionList.append(ball3Item)

        groupCmd = parentHierarchy.createGroupCmd(ufeSelectionList,
                                                  newGroupName)
        groupCmd.execute()

        parentChildrenPost = parentHierarchy.children()
        self.assertEqual(len(parentChildrenPost), 5)

        # The command will now append a number 1 at the end to match the naming
        # convention in Maya.
        newGroupPath = parentPath + ufe.PathComponent("newGroup1")

        # Make sure the new group item has the correct Usd type
        newGroupItem = ufe.Hierarchy.createItem(newGroupPath)
        newGroupPrim = usdUtils.getPrimFromSceneItem(newGroupItem)
        newGroupType = newGroupPrim.GetTypeName()
        self.assertEqual(newGroupType, 'Xform')

        childPaths = set([child.path() for child in parentChildrenPost])

        self.assertTrue(newGroupPath in childPaths)
        self.assertTrue(ball5Path not in childPaths)
        self.assertTrue(ball3Path not in childPaths)

        groupCmd.undo()

        parentChildrenUndo = parentHierarchy.children()
        self.assertEqual(len(parentChildrenUndo), 6)

        childPathsUndo = set([child.path() for child in parentChildrenUndo])
        self.assertTrue(newGroupPath not in childPathsUndo)
        self.assertTrue(ball5Path in childPathsUndo)
        self.assertTrue(ball3Path in childPathsUndo)

        groupCmd.redo()

        parentChildrenRedo = parentHierarchy.children()
        self.assertEqual(len(parentChildrenRedo), 5)

        childPathsRedo = set([child.path() for child in parentChildrenRedo])
        self.assertTrue(newGroupPath in childPathsRedo)
        self.assertTrue(ball5Path not in childPathsRedo)
        self.assertTrue(ball3Path not in childPathsRedo)