Skip to content

Commit

Permalink
Merge pull request #2204 from Autodesk/boudrey/MAYA-114678/exportroots
Browse files Browse the repository at this point in the history
MAYA-114678 [Github #1739] USDExport: using "parentScope" and "export…
  • Loading branch information
seando-adsk authored Apr 6, 2022
2 parents da2e55c + a4b8ada commit ab78c8e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/mayaUsd/fileio/writeJobContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,14 @@ SdfPath UsdMayaWriteJobContext::ConvertDagToUsdPath(const MDagPath& dagPath) con
path = path.GetParentPath();
}

path = _GetRootOverridePath(mArgs, path);

if (!mParentScopePath.IsEmpty()) {
// Since path is from MDagPathToUsdPath, it will always be
// an absolute path...
path = path.ReplacePrefix(SdfPath::AbsoluteRootPath(), mParentScopePath);
}

return _GetRootOverridePath(mArgs, path);
return path;
}

UsdMayaWriteJobContext::_ExportAndRefPaths
Expand Down
1 change: 1 addition & 0 deletions test/lib/usd/translators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ set(TEST_SCRIPT_FILES
## XXX: This test is disabled by default since it requires the RenderMan for Maya plugin.
# testUsdExportRfMLight.py
testUsdExportRoots.py
testUsdExportRootsAndParentScope.py
testUsdExportSelection.py
testUsdExportSelectionHierarchy.py
testUsdExportShadingInstanced.py
Expand Down
58 changes: 58 additions & 0 deletions test/lib/usd/translators/testUsdExportRootsAndParentScope.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env mayapy
#
# Copyright 2022 Autodesk
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import os
import unittest

from maya import cmds
from maya import standalone

import filecmp

import fixturesUtils

class testUsdExportRoot(unittest.TestCase):

@classmethod
def setUpClass(cls):
inputPath = fixturesUtils.setUpClass(__file__)

@classmethod
def tearDownClass(cls):
standalone.uninitialize()

def testExport_exportRoots_And_parentScope(self):
cmds.file(new=True, force=True)

r = cmds.sphere( name='pSphere1', polygon=1, r=10 )

# Run this command to check exportRoots works:
usdFile_roots = os.path.abspath('roots.usda')
cmds.mayaUSDExport(file=usdFile_roots, exportRoots=['|pSphere1'])

#Then run this command to check parentScope works:
usdFile_parent = os.path.abspath('parent.usda')
cmds.mayaUSDExport(file=usdFile_parent, parentScope='/geo_GRP')

# Then attempt this command with both flags to see the error:
usdFile_both = os.path.abspath('both.usda')
cmds.mayaUSDExport(file=usdFile_both, exportRoots=['|pSphere1'], parentScope='/geo_GRP')

self.assertTrue(filecmp.cmp(usdFile_parent, usdFile_both))

if __name__ == '__main__':
unittest.main(verbosity=2)

0 comments on commit ab78c8e

Please sign in to comment.