Kemote
October 17, 2025, 4:08pm
1
Hey everyone,
I’m trying to reference a USD file in Maya using the cmds.file() command, and it works almost perfectly. Unfortunately, I’m unable to create a reference to a specific prim variant within the USD file.
I know it’s possible to select it when creating a reference manually in the “Reference Editor,” but I’m looking for a way to do this using Python.
Does anyone have any ideas?
dhruvgovil
(Dhruv Govil)
October 18, 2025, 6:33pm
2
If you use the specific Maya usd import command, it has flags you can provide for more control over your inputs
# Common Plug-in Commands
This read-me documents the common commands that are shared by the various
USD plug-ins made by Autodesk and Pixar.
## Common Plug-in Contents
The common parts of Maya USD plug-in provides base commands to import and
export USD files from scripts. The name of the command as seen by the
end-user will vary for each specific plug-in. In the following table,
we give an example of what the final command name would be in Maya,
in this instance for the mayaUsd plug-in.
| Class Name | Example Real Cmd Name | Purpose |
| ------------------------------ | ------------------------ | -------------------------------------- |
| MayaUSDImportCommand | mayaUSDImport | Command to import from a USD file |
| MayaUSDExportCommand | mayaUSDExport | Command to export into a USD file |
| MayaUSDListShadingModesCommand | mayaUSDListShadingModes | Command to get available shading modes |
| EditTargetCommand | mayaUsdEditTarget | Command to set or get the edit target |
| LayerEditorCommand | mayaUsdLayerEditor | Manipulate layers |
This file has been truncated. show original
1 Like
Kemote
October 19, 2025, 10:36pm
3
Thanks, it’s very helpful. But it’s not 100% what I need. For regular importing, it works perfectly. But I need to reference this USD file, not just import it. I tried to pass the primVariant flag using options in the cmds.file(r=true, options=…) command without any luck.
Hi @Kemote ,
It’s not clear what you need, but maybe this test can give you some ideas on how to accomplish that?
# being interpreted.
ballFilePath = os.path.normpath(testUtils.getTestScene('ballset', 'StandaloneScene', 'top_layer.usda')).replace('\\', '/')
mel.eval('source \"mayaUsd_createStageFromFile.mel\"')
shapeNode = mel.eval('mayaUsd_createStageFromFilePath(\"'+ballFilePath+'\")')
mayaSel = cmds.ls(sl=True)
self.assertEqual(1, len(mayaSel))
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())