Example #1
0
    def test_getMayaPathFromUsdPrim_reopenStaticImport(self):
        """Saving and reopening a Maya scene with static translated prims should work."""

        cmds.AL_usdmaya_ProxyShapeImportPrimPathAsMaya(self._stageA.proxyName, primPath=str(self._stageA.prim.GetPath()))

        # Save
        _file = tempfile.NamedTemporaryFile(delete=False, suffix=".ma")
        with _file:
            cmds.file(rename=_file.name)
            cmds.file(save=True, force=True)
        _file.close()

        # Re-open
        cmds.file(_file.name, open=True, force=True)

        # Refresh data, stage wrapper is out of date
        _stageC = self.MayaUsdTestData()
        _stageC.poly = self._stageA.poly
        _stageC.proxyName = self._stageA.proxyName
        _stageC.proxy = AL.usdmaya.ProxyShape.getByName(_stageC.proxyName)
        _stageC.stage = _stageC.proxy.getUsdStage()
        _stageC.prim = _stageC.stage.GetPrimAtPath("/{}".format(_stageC.poly))

        # Test
        cmds.AL_usdmaya_ProxyShapeSelect(_stageC.proxyName, replace=True, primPath=str(_stageC.prim.GetPath()))
        self.assertTrue(cmds.objExists(_stageC.poly))
        result = _stageC.proxy.getMayaPathFromUsdPrim(_stageC.prim)
        expected = cmds.ls(_stageC.poly, long=True)[0]
        self.assertEqual(result, expected)

        # Cleanup
        os.remove(_file.name)
Example #2
0
    def test_getMayaPathFromUsdPrim_staticImport(self):
        """Force import a prim."""

        cmds.AL_usdmaya_ProxyShapeImportPrimPathAsMaya(self._stageA.proxyName, primPath=str(self._stageA.prim.GetPath()))
        result = self._stageA.proxy.getMayaPathFromUsdPrim(self._stageA.prim)
        expected = cmds.ls(self._stageA.poly, long=True)[0]

        self.assertEqual(result, expected)