[EMSUSD-637] MayaUSDExportCommand doesn't export 'default' value of USD_ATTR_purpose correctly
- Dominant language
- Wolfram Language
- Stars
- 905
- Forks
- 223
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 17
Description
**Describe the bug**
If we set the attribute `USD_ATTR_purpose` to `default`, which is described as a valid value in the MayaUSDExportCommand documentation, the resulting USD file has a blank entry for that field. Setting the attribute to other values described in the docs, or even strings not mentioned in the docs, will result in that value being written into the exported USD file. Only the `default` value will result in a blank field (as far as my testing shows).
**Steps to reproduce**
Steps to reproduce the behavior:
```
cmds.polyPlane(name="testPlane", sx=1, sy=1)
cmds.addAttr("testPlane", longName="USD_ATTR_purpose", dataType="string")
cmds.setAttr("testPlane.USD_ATTR_purpose", "render", type='string')
cmds.mayaUSDExport(file=r"C:\tmp\usd_purpose_render.usda", exportRoots=["testPlane"])
cmds.setAttr("testPlane.USD_ATTR_purpose", "default", type='string')
cmds.mayaUSDExport(file=r"C:\tmp\usd_purpose_default.usda", exportRoots=["testPlane"])
cmds.setAttr("testPlane.USD_ATTR_purpose", "foo", type='string')
cmds.mayaUSDExport(file=r"C:\tmp\usd_purpose_foo.usda", exportRoots=["testPlane"])
```
Execute the above python in a new scene, substituting the output file paths to suit your setup. Open and observe the results, as below (truncated for brevity).
**usd_purpose_render.usda:**
```
#usda 1.0
(
defaultPrim = "testPlane"
metersPerUnit = 0.01
upAxis = "Y"
)
def Mesh "testPlane" (
prepend apiSchemas = ["MaterialBindingAPI"]
kind = "component"
)
{
uniform bool doubleSided = 1
float3[] extent = [(-0.5, 0, -0.5), (0.5, 0, 0.5)]
int[] faceVertexCounts = [4]
int[] faceVertexIndices = [0, 1, 3, 2]
rel material:binding =
point3f[] points = [(-0.5, 0, 0.5), (0.5, 0, 0.5), (-0.5, 0, -0.5), (0.5, 0, -0.5)]
texCoord2f[] primvars:st = [(0, 0), (1, 0), (0, 1), (1, 1)] (
customData = {
dictionary Maya = {
token name = "map1"
}
}
interpolation = "faceVarying"
)
int[] primvars:st:indices = [0, 1, 3, 2]
uniform token purpose = "render"
def Scope "mtl"
{
def Material "initialShadingGroup"
{
}
}
}
```
**usd_purpose_default.usda:**
```
#usda 1.0
...
def Mesh "testPlane" (
...
)
{
...
uniform token purpose
...
}
```
**usd_purpose_foo.usda:**
```
#usda 1.0
...
def Mesh "testPlane" (
...
)
{
...
uniform token purpose = "foo"
...
}
```
**Expected behavior**
I would expect the value `default` to be written into the field for that value. Default is a valid purpose and is different to an empty field, as when it comes to composition I may wish to override this field, from a lower layer in the stack, e.g. from `proxy` to `default`, but this is impossible as setting to attribute to `default` results in a blank field, which on composition will fallback to the other layer.
**Specs (if applicable):**
- Windows 10
- Maya 2022.4
- Maya USD 0.24.0 as per the downloadable binaries
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.