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

MAYA-108214 - Attributes categorized by schema #964

Merged
merged 2 commits into from
Dec 4, 2020

Conversation

seando-adsk
Copy link
Collaborator

MAYA-108214 - Attributes categorized by schema

  • New "usdschemabase" template which is at top level of the schema inheritance scheme so all prim types will use it. All the node type templates are deprecated and will be removed in the future.

* New "usdschemabase" template which is at top level
  of the schema inheritance scheme so all prim types
  will use it. All the node type templates are
  deprecated and will be removed in the future.
@seando-adsk seando-adsk requested a review from ppt-adsk December 3, 2020 18:51
@seando-adsk seando-adsk added enhancement New feature or request requires maya This issue requires changes in Maya labels Dec 3, 2020
set(MAYAUSD_AE_TEMPLATES base camera capsule cone cube cylinder material mesh scope shader sphere xform)

# Nov 2020: new system just uses a single schema base template file.
list(APPEND MAYAUSD_AE_TEMPLATES usdschemabase)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new single python template since all schemas end up deriving from UsdSchemaBase. So the new ufe template inheritance loading (changes in Maya) will always find this file.

super(AEBaseTemplate, self).__init__(ufeSceneItem)

def buildUI(self, ufeSceneItem):
super(AEBaseTemplate, self).buildUI(ufeSceneItem)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved all the code from this base to the new "usdschemabase". This base template now derives from the usdschemabase (line 10).

I've also made all these templates non-loadable for Maya PR 121 or later.

@@ -189,7 +189,7 @@ def childrenNames(children):
cmds.undo() # undo duplication
cmds.undo() # undo deletion

@unittest.skipUnless(mayaUtils.previewReleaseVersion() >= 122, 'Requires Maya fixes only available in Maya Preview Release 122 or later.')
@unittest.skipUnless(mayaUtils.previewReleaseVersion() >= 121, 'Requires Maya fixes only available in Maya Preview Release 121 or later.')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fowlertADSK PR121 is the next one to go out, so isn't that the tag you meant to use?

Comment on lines +24 to +33
def createSection(self, layoutName, attrList, collapse=False):
# We create the section named "layoutName" if at least one
# of the attributes from the input list exists.
for attr in attrList:
if self.attrS.hasAttribute(attr):
with ufeAeTemplate.Layout(self, layoutName, collapse):
# Note: addControls will silently skip any attributes
# which do not exist.
self.addControls(attrList)
return
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unchanged from ae/base/ae_template.py

Comment on lines 85 to 106
def createTransformAttributesSection(self, ufeSceneItem, sectionName, attrsToAdd):
# Get the xformOp order and add those attributes (in order)
# followed by the xformOp order attribute.
allAttrs = self.attrS.attributeNames
prim = mu.getPrimFromRawItem(ufeSceneItem.getRawAddress())
geomX = UsdGeom.Xformable(prim)
xformOps = geomX.GetOrderedXformOps()
xformOpOrderNames = [op.GetOpName() for op in xformOps]
xformOpOrderNames.append(UsdGeom.Tokens.xformOpOrder)
# Don't use createSection because we want a sub-sections.
with ufeAeTemplate.Layout(self, sectionName):
with ufeAeTemplate.Layout(self, 'Transform Attributes'):
attrsToAdd.remove(UsdGeom.Tokens.xformOpOrder)
self.addControls(xformOpOrderNames)

# Get the remainder of the xformOps and add them in an Unused section.
xformOpUnusedNames = fnmatch.filter(allAttrs, 'xformOp:*')
xformOpUnusedNames = [ele for ele in xformOpUnusedNames if ele not in xformOpOrderNames]
self.createSection('Unused Transform Attributes', xformOpUnusedNames, collapse=True)

# Then add any reamining Xformable attributes
self.addControls(attrsToAdd)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unchanged from ae/base/ae_template.py

Comment on lines +108 to +124
def buildUI(self, ufeSceneItem):
usdSch = Usd.SchemaRegistry()

# We use UFE for the ancestor node types since it caches the
# results by node type.
for schemaType in ufeSceneItem.ancestorNodeTypes():
schemaType = usdSch.GetTypeFromName(schemaType)
schemaTypeName = schemaType.typeName
sectionName = self.sectionNameFromSchema(schemaTypeName)
if schemaType.pythonClass:
attrsToAdd = schemaType.pythonClass.GetSchemaAttributeNames(False)

# We have a special case when building the Xformable section.
if schemaTypeName == 'UsdGeomXformable':
self.createTransformAttributesSection(ufeSceneItem, sectionName, attrsToAdd)
else:
self.createSection(sectionName, attrsToAdd)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method completely changed from ae/base/ae_template.py. We no longer have hard-coded sections and attributes. Instead using the ancestor node types I get all the schemas and for each one get the attributes.

The only exception is the Xformable, where we still display the transform attributes by xformoporder.

Comment on lines 35 to 81
def sectionNameFromSchema(self, schemaTypeName):
'''Return a section name from the input schema type name. This section
name is a pretty name used in the UI.'''

# List of special rules for adjusting the base schema names.
prefixToAdjust = {
'UsdAbc' : '',
'UsdGeomGprim' : 'GeometricPrim',
'UsdGeom' : '',
'UsdHydra' : '',
'UsdImagingGL' : '',
'UsdLux' : '',
'UsdMedia' : '',
'UsdRender' : '',
'UsdRi' : '',
'UsdShade' : '',
'UsdSkelAnimation' : 'SkelAnimation',
'UsdSkelBlendShape': 'BlendShape',
'UsdSkelSkeleton': 'Skeleton',
'UsdSkelRoot' : 'SkelRoot',
'UsdUI' : '',
'UsdUtils' : '',
'UsdVol' : ''
}
for p, r in prefixToAdjust.items():
if schemaTypeName.startswith(p):
schemaTypeName = schemaTypeName.replace(p, r, 1)
break

# Put a space in the name when proceeded with a capital letter.
# Exceptions: Number followed by capital
# Multiple capital letters together
catName = str(schemaTypeName[0])
nbChars = len(schemaTypeName)
for i in range(1, nbChars):
if schemaTypeName[i].isupper() and not schemaTypeName[i-1].isdigit():
if (i < (nbChars-1)) and not schemaTypeName[i+1].isupper():
catName = catName + str(' ') + str(schemaTypeName[i])
else:
catName = catName + str(schemaTypeName[i])
elif schemaTypeName[i] == '_':
continue
else:
catName = catName + str(schemaTypeName[i])

# Make each word start with an uppercase.
catName = catName.title()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New helper to create the section title from the schema name. There are a bunch of rules (see JIRA item) for how to parse and format the string.

Copy link
Collaborator

@ppt-adsk ppt-adsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just this minor comment detail, but otherwise LGTM.

@@ -0,0 +1,124 @@
import fnmatch
import ufe
import mayaUsd.ufe as mu
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mu?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that matter? Isn't this just a name to use instead of "mayaUsd.ufe.xxx"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely correct in saying that there is no problem on executing the above code and getting correct results. Just wondering about the very terse name... m can be Maya or maya-usd, u can be USD or UFE... Kinda hard to find a more descriptive name that's shorter than mayaUsd.ufe, I guess... You can leave it as is if you like.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your right. I only used it once, so I've just removed that

schemaTypeName = schemaTypeName.replace(p, r, 1)
break

# Put a space in the name when proceeded with a capital letter.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite sure here, but think you mean either "preceded by" or "followed by".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, typo

@seando-adsk seando-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Dec 3, 2020
@seando-adsk
Copy link
Collaborator Author

@kxl-adsk If the PF passes, please merge whenever.

@kxl-adsk kxl-adsk merged commit d754d30 into dev Dec 4, 2020
@kxl-adsk kxl-adsk deleted the donnels/MAYA-108214/attributes_categorized_by_schema branch December 4, 2020 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready-for-merge Development process is finished, PR is ready for merge requires maya This issue requires changes in Maya
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants