-
Notifications
You must be signed in to change notification settings - Fork 202
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
MAYA-108214 - Attributes categorized by schema #964
Conversation
* 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.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.') |
There was a problem hiding this comment.
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?
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 |
There was a problem hiding this comment.
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
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) |
There was a problem hiding this comment.
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
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) |
There was a problem hiding this comment.
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.
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() |
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mu?
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, typo
* Code review comments.
@kxl-adsk If the PF passes, please merge whenever. |
MAYA-108214 - Attributes categorized by schema