Autodesk / Autodesk/maya-usd

replacing reference with variations for usd and fbx doesn't work if fbx has joints

Open
#4,496 0 comments 0 reactions 1 assignee Claimed by @santosg87 View on GitHub
bug
Dominant language
Wolfram Language
Stars
905
Forks
223
Avg merge
2d 9h
Merged PRs (30d)
17

Description

**Describe the bug**
I'm trying to let a user select a prim that has a reference to a usd asset and create a variation with a maya reference to a fbx file. If the fbx just has geometry in it everything works, but if the fbx has joints in it the original usd reference doesn't go away when switching to the fbx variation

**Steps to reproduce**
Steps to reproduce the behavior:
```
#usda 1.0
(
defaultPrim = "scene"
)

def Xform "scene"
{
over Xform "asset" (
instanceable = true
prepend references = @asset.usd@
)
{
float3 xformOp:rotateXYZ = (0, 0, 0)
float3 xformOp:scale = (1, 5.37646, 1)
double3 xformOp:translate = (-236.27437, 0, -28.00635)
float3 xformOp:translate:pivot = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "xformOp:rotateXYZ", "xformOp:scale", "!invert!xformOp:translate:pivot"]
}
}
```

```
import mayaUsd
from mayaUsd.lib import proxyAccessor as pa

from pxr import Sdf

def add_fbx_variation():
stage_path, prim_path = pa.getSelectedDagAndPrim()

stage = mayaUsd.ufe.getStage(stage_path)
obj = stage.DefinePrim(prim_path, 'Xform')

prim = obj.GetPrim()
prim.SetTypeName('Xform')
obj.SetInstanceable(False)

usd_path = ''
refs = prim.GetMetadata("references").ApplyOperations([])
for ref in refs:
usd_path = ref.assetPath

if not usd_path:
raise ValueError('unable to determine path to usd file')

fbx_path = usd_path.replace('.usd', '.fbx')

obj.GetReferences().ClearReferences()
obj.GetReferences().SetReferences([])

vset = obj.GetVariantSets().AddVariantSet('file_version')
vset.AddVariant('usd_file')
vset.SetVariantSelection('usd_file')
with vset.GetVariantEditContext():
obj.GetReferences().AddReference(usd_path)
obj.SetInstanceable(True)

vset.AddVariant('fbx_file')
vset.SetVariantSelection('fbx_file')
with vset.GetVariantEditContext():
mayaPrim = stage.DefinePrim(f'{prim_path}/fbx', 'MayaReference')
attr = mayaPrim.GetPrim().CreateAttribute('mayaAutoEdit', Sdf.ValueTypeNames.Bool)
attr.Set(1)
attr = mayaPrim.GetPrim().CreateAttribute('mayaNamespace', Sdf.ValueTypeNames.String)
attr.Set(prim.GetName())
attr = mayaPrim.GetPrim().CreateAttribute('mayaReference', Sdf.ValueTypeNames.Asset)
attr.Set(fbx_path)

if __name__ == '__main__':
add_fbx_variation()
```

**Expected behavior**
behavior would be the same if there are joints in the fbx or not

**Attachments**

Image
the geometry and looks would be gone if the fbx doesn't have any joints

**Specs (if applicable):**
- OS & version [e.g. Windows 11]
- Maya version [e.g. Maya 2026.2]

**Additional context**
Add any other context about the problem here.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.