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

EMSUSD-1120 - Stage loading problems using MEL proc #3667

Merged
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
4 changes: 4 additions & 0 deletions plugin/adsk/scripts/mayaUsd_createStageFromFile.mel
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,9 @@ global proc mayaUsd_createStageFromFile()

global proc string mayaUsd_createStageFromFilePath(string $usdFile)
{
// This proc is used by the unit tests (which run in standalone mode).
// In that case we need to make sure the optionVars are initialized as
// they are queried in doCreateStage().
setOptionVars(false);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what happens is on line 141 it would do:
string $ppath = optionVar -q stageFromFile_primPath;
If we are running in standalone (say from a unit test) the options vars would not have been init, and in Maya when you query an option var that doesn't exist it returns 0. The MEL code above converts that to a string and you get "0". That would then we set as the primPath on the stage. In Dan's new code this is not a valid primPath so the compute would bail early. With this fix the option vars are init and it will set "" as the primpath which converts to the root prim "/" and the compute works.

return doCreateStage($usdFile);
}
12 changes: 12 additions & 0 deletions test/lib/testMayaUsdCreateStageCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ def testCreateStageFromFile(self):
nt = cmds.nodeType(shapeNode)
self.assertEqual('mayaUsdProxyShape', nt)

# Verify that the we have a good stage.
stage = mayaUsd.ufe.getStage(shapeNode)
self.assertTrue(stage)

# This stage has five layers.
layerStack = stage.GetLayerStack()
self.assertEqual(5, len(layerStack))

# Finally, verify that we can get at least one of the ball prims.
ballPrim = stage.GetPrimAtPath('/Room_set/Props/Ball_1')
self.assertTrue(ballPrim.IsValid())
Comment on lines +80 to +90
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some test cases to ensure the stage was correctly loaded.


# Verify that the shape node has the correct file path.
filePathAttr = cmds.getAttr(shapeNode+'.filePath')
self.assertTrue(self.samefile(filePathAttr, ballFilePath))
Expand Down