Search code examples
pythonmaya

Maya referenceQuery namespace bug


I'm trying to get a reference's namespace with this command:

cmds.referenceQuery(filePath, namespace=True)

This works as expected on loaded and unloaded references. I noticed I get an error if I try this with a reference that has never been loaded before. But if I load it then unload it, it works. Is this a bug? How can I get its namespace without getting this error?

The error it throws is as follows:

# Error: RuntimeError: file <maya console> line 1: Cannot find the associated namespace. #

Edit:

Just noticed that the namespace doesn't actually exist in the namespace editor until the reference is loaded. Still, is there some way to get this?


Solution

  • Found I can get its namespace this way.

    cmds.file(filePath, q = True, namespace = True)