Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed anonymous layer import #1086

Merged
merged 1 commit into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/mayaUsd/commands/baseImportCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ MStatus MayaUSDImportCommand::doIt(const MArgList& args)
mFileName = UsdMayaUtil::convert(tmpVal);

// Use the usd resolver for validation (but save the unresolved)
if (ArGetResolver().Resolve(mFileName).empty()) {
if (ArGetResolver().Resolve(mFileName).empty()
&& !SdfLayer::IsAnonymousLayerIdentifier(mFileName)) {
TF_RUNTIME_ERROR(
"File '%s' does not exist, or could not be resolved. "
"Exiting.",
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 @@ -44,6 +44,7 @@ set(TEST_SCRIPT_FILES
testUsdExportStroke.py
testUsdExportUserTaggedAttributes.py
testUsdExportVisibilityDefault.py
testUsdImportAnonymousLayer.py
testUsdImportCamera.py
testUsdImportColorSets.py
testUsdImportDisplacement.py
Expand Down
57 changes: 57 additions & 0 deletions test/lib/usd/translators/testUsdImportAnonymousLayer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env mayapy
#
# Copyright 2021 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 pxr import Usd, Sdf

from maya import cmds
from maya import standalone

import fixturesUtils

class testUsdImportSessionLayer(unittest.TestCase):

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

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

def testUsdImport(self):
"""
This test executes import from an anonymous layer as per GitHub Discussion
https://github.com/Autodesk/maya-usd/discussions/1069
"""

layer = Sdf.Layer.CreateAnonymous()
stage = Usd.Stage.Open(layer)
stage.DefinePrim('/Foo', 'Xform')

cmds.mayaUSDImport(f=layer.identifier, primPath='/')

expectedMayaNodesSet = set([
'|Foo'])
mayaNodesSet = set(cmds.ls('|Foo*', long=True))
self.assertEqual(expectedMayaNodesSet, mayaNodesSet)


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