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-1890 show Def in AE #4081

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 12 additions & 4 deletions lib/usdUfe/ufe/UsdSceneItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,20 @@ std::vector<std::string> UsdSceneItem::ancestorNodeTypes() const
return strAncestorTypes;

// Get the actual schema type from the prim definition.
const TfType& schemaType = _prim.GetPrimTypeInfo().GetSchemaType();
if (!schemaType) {
// No schema type, return empty ancestor types.
return strAncestorTypes;
const TfType* schemaTypePtr = &_prim.GetPrimTypeInfo().GetSchemaType();
if (!*schemaTypePtr) {
// Typeless prim (for example, pure Def) don't have a schema type,
// so we pretend that they have the base schema so that it can be
// properly displayed in the Attribute Editor.
schemaTypePtr = &TfType::Find<UsdSchemaBase>();
if (!*schemaTypePtr) {
// No schema type, return empty ancestor types.
return strAncestorTypes;
}
}

const TfType& schemaType = *schemaTypePtr;

// According to the USD docs GetAllAncestorTypes() is expensive, so we keep a cache.
static std::map<TfType, std::vector<std::string>> ancestorTypesCache;
const auto iter = ancestorTypesCache.find(schemaType);
Expand Down
46 changes: 45 additions & 1 deletion test/lib/testAttributeEditorTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def testAEForLight(self):
startLayout = cmds.formLayout(primFormLayout, query=True, fullPathName=True)
self.assertIsNotNone(startLayout, 'Could not get full path for %s formLayout' % primName)

# Augment the maixmum diff size to get better error message when comparing the lists.
# Augment the maximum diff size to get better error message when comparing the lists.
self.maxDiff = 2000

actualSectionLabels = self.findAllFrameLayoutLabels(startLayout)
Expand All @@ -516,6 +516,50 @@ def testAEForLight(self):
self.assertIn('Display', actualSectionLabels[-4:])
self.assertIn('Metadata', actualSectionLabels[-4:])

def testAEForDefWithSchema(self):
'''Test that the expected sections are created for def with added schema.'''
proxyShape = mayaUsd_createStageWithNewLayer.createStageWithNewLayer()
proxyShapePath = ufe.PathString.path(proxyShape)
proxyShapeItem = ufe.Hierarchy.createItem(proxyShapePath)

# Create a Def primt via contextOps menu. Not all versions of Maya automatically
pierrebai-adsk marked this conversation as resolved.
Show resolved Hide resolved
# select the prim from 'Add New Prim', so always select it here.
proxyShapeContextOps = ufe.ContextOps.contextOps(proxyShapeItem)
proxyShapeContextOps.doOp(['Add New Prim', 'Def'])
primName = 'Def1'
fullPrimPath = proxyShape + ',/%s' % primName
cmds.select(fullPrimPath)

# Add Light schema to the Def prim.
cmds.mayaUsdSchema(fullPrimPath, schema='LightAPI')

# Make sure the AE is visible.
import maya.mel
maya.mel.eval('openAEWindow')

# Note: for Def, the nodeType command returns ''.
primFormLayout = self.attrEdFormLayoutName('')
self.assertTrue(cmds.formLayout(primFormLayout, exists=True), 'Layout for %s was not found\n' % primName)

startLayout = cmds.formLayout(primFormLayout, query=True, fullPathName=True)
self.assertIsNotNone(startLayout, 'Could not get full path for %s formLayout' % primName)

# Augment the maximum diff size to get better error message when comparing the lists.
self.maxDiff = 2000

actualSectionLabels = self.findAllFrameLayoutLabels(startLayout)

# Note: different version of USD can have different schemas,
# so we only compare the ones we are interested in verifying.
expectedInitialSectionLabels = [
'Light ',
'Light Link Collection ',
'Shadow Link Collection ']
self.assertListEqual(
actualSectionLabels[0:len(expectedInitialSectionLabels)],
expectedInitialSectionLabels)
self.assertIn('Metadata', actualSectionLabels)

def testAECustomAttributeCallback(self):
'''Test that the custm atribute callbacks work.'''

Expand Down