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-108220 - As a user, on the prim AE template I'd like to see arra… #1267

Merged
merged 3 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
35 changes: 31 additions & 4 deletions lib/mayaUsd/resources/ae/usdschemabase/ae_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __del__(self):

def __call__(self, notification):
if isinstance(notification, ufe.AttributeValueChanged):
if notification.name() == "xformOpOrder":
if notification.name() == UsdGeom.Tokens.xformOpOrder:
mel.eval("evalDeferred(\"AEbuildControls\");")

def onCreate(self, *args):
Expand Down Expand Up @@ -229,17 +229,27 @@ def __init__(self, ufeSceneItem):

# Get the UFE Attributes interface for this scene item.
self.attrS = ufe.Attributes.attributes(self.item)
self.suppressedAttrs = []

self.showArrayAttributes = False
if cmds.optionVar(exists="mayaUSD_AEShowArrayAttributes"):
self.showArrayAttributes = cmds.optionVar(query="mayaUSD_AEShowArrayAttributes")

cmds.editorTemplate(beginScrollLayout=True)
self.buildUI()
cmds.editorTemplate(addExtraControls=True)
self.createMetadataSection()
cmds.editorTemplate(endScrollLayout=True)

@staticmethod
def addControls(controls):

def addControls(self, controls):
for c in controls:
cmds.editorTemplate(addControl=[c])
if c not in self.suppressedAttrs:
cmds.editorTemplate(addControl=[c])

def suppress(self, control):
cmds.editorTemplate(suppress=control)
self.suppressedAttrs.append(control)

@staticmethod
def defineCustom(customObj, attrs=[]):
Expand Down Expand Up @@ -297,6 +307,7 @@ def createTransformAttributesSection(self, sectionName, attrsToAdd):
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'):
Expand Down Expand Up @@ -326,6 +337,8 @@ def createMetadataSection(self):
def buildUI(self):
usdSch = Usd.SchemaRegistry()

self.suppressArrayAttribute()

# We use UFE for the ancestor node types since it caches the
# results by node type.
for schemaType in self.item.ancestorNodeTypes():
Expand All @@ -340,3 +353,17 @@ def buildUI(self):
self.createTransformAttributesSection(sectionName, attrsToAdd)
else:
self.createSection(sectionName, attrsToAdd)

def suppressArrayAttribute(self):
# Suppress all array attributes except UsdGeom.Tokens.xformOpOrder
if not self.showArrayAttributes:
for attrName in self.attrS.attributeNames:
if attrName != UsdGeom.Tokens.xformOpOrder and self.isArrayAttribute(attrName):
self.suppress(attrName)

def isArrayAttribute(self, attrName):
if self.attrS.attributeType(attrName) == ufe.Attribute.kGeneric:
attr = self.prim.GetAttribute(attrName)
typeName = attr.GetTypeName()
return typeName.isArray
return False
3 changes: 2 additions & 1 deletion plugin/adsk/scripts/mayaUSDRegisterStrings.mel
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ global proc mayaUSDRegisterStrings() {
register("kSaveOptionNoPromptAnn", "You can re-enable this prompt under File|Save Scene Options.");
register("kSaveOptionTitle", "Save USD Options");
register("kSaveOptionUnsavedEdits", "You have unsaved USD edits. How would you like to proceed?");
register("kShowArrayAttributes", "Show Array Attributes");
register("kUSDSelectionMode", "USD Selection Mode");
register("kUSDSelectionModeAnn", "Choose a selection mode to reflect changes when you select prims in the Viewport and Outliner. Note: Default fallback selection mode is by prim.");
register("kUSDSelectionModeAssemblyAnn", "Selection mode for prims set to assembly kind. Tip: Set assembly kind in the Attribute Editor > Metadata to prims that are part of an important group.");
Expand All @@ -104,8 +105,8 @@ global proc mayaUSDRegisterStrings() {
register("kUSDSelectionModeSubComponentAnn", "Selection mode for prims set to subcomponent kind. Tip: Set subcomponent kind in the Attribute Editor > Metadata to prims that are an individual asset.");
register("kTimeAnn", "Edits the current time value of a stage, which corresponds to the animation frame drawn in the viewport. By default, this value connects to Maya's global time node.");
register("kTipYouCanChooseMultipleFiles", "<b>Tip:</b> You can choose multiple files.");
register("kUnloadAll", "Unload All");
register("kUniversalSceneDescription", "Universal Scene Description");
register("kUnloadAll", "Unload All");
register("kUsdFileOptions", "USD File Options");
register("kUsdOptionsFrameLabel", "Universal Scene Description (USD) Options");
register("kSaveOption2GBWarning", "<b>Important</b>: per layer, any data exceeding the limit of 2GB will not be saved.");
Expand Down
54 changes: 54 additions & 0 deletions plugin/adsk/scripts/mayaUsdMenu.mel
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ proc removeMenuCallback(string $menuName, string $cmd) {

}

///////////////////////////////////////////////////////////////////////////////
// findAEMenu
// Helper function to find attribute editor menu.
proc string findAEMenu(string $menuLabel)
{
global string $gAEMenuBarLayoutName;

string $fp = `menuBarLayout -q -fullPathName $gAEMenuBarLayoutName`;
string $kids[] = `menuBarLayout -q -ma $gAEMenuBarLayoutName`;
for ($menu in $kids)
{
string $fpMenu = $fp + "|" + $menu;
if ($menuLabel == `menu -q -label $fpMenu`) {
string $existingCallbacks = `menu -q -pmc $fpMenu`;
return $fpMenu;
}
}
return "";
}

///////////////////////////////////////////////////////////////////////////////
// mayaUSD_setSelectionKind
// Helper function to set the selection kind mode
Expand Down Expand Up @@ -361,6 +381,26 @@ global proc mayaUsdMenu_generalEditorsMenuCallback() {
removeMenuCallback(`setParent -q -menu`, "mayaUsdMenu_generalEditorsMenuCallback");
}

///////////////////////////////////////////////////////////////////////////////
// mayaUsdMenu_aeShowMenuCallback
// Maya USD Attribute Editor Show menu callback.
// Note: Maya is using a post callback to build it's menu.
// The maya's callback delete all menu item each time
// the menu is display, so we also need to create all
// our menu item each time.
global proc mayaUsdMenu_aeShowMenuCallback(string $aeShowMenu)
{
string $mayaVersion = getMayaMajorVersion();
int $isEnable = `optionVar -q "mayaUSD_AEShowArrayAttributes"`;

setParent -menu $aeShowMenu;
menuItem -divider true -dividerLabel `getMayaUsdString("kUniversalSceneDescription")`;
menuItem -label `getMayaUsdString("kShowArrayAttributes")`
-checkBox $isEnable
-version $mayaVersion
-command "optionVar -intValue \"mayaUSD_AEShowArrayAttributes\" #1; AEbuildControls;";
}

///////////////////////////////////////////////////////////////////////////////
// initCreateMenu
// setup the items in Maya's "Create" menu
Expand Down Expand Up @@ -413,6 +453,18 @@ proc termSelectMenu() {
}
}

proc initAEShowMenu()
{
string $aeShowMenu = findAEMenu(uiRes("m_showEditor.kShow"));
addMenuCallback($aeShowMenu, "mayaUsdMenu_aeShowMenuCallback " + $aeShowMenu);
}

proc termAEShowMenu()
{
string $aeShowMenu = findAEMenu(uiRes("m_showEditor.kShow"));
removeMenuCallback($aeShowMenu, "mayaUsdMenu_aeShowMenuCallback");
}

///////////////////////////////////////////////////////////////////////////////
// mayaUsdMenu_loadui
// main entry point on plugin load
Expand All @@ -421,6 +473,7 @@ global proc mayaUsdMenu_loadui() {
initRuntimeCommands();
initCreateMenu();
initSelectMenu();
initAEShowMenu();

// if the current selection kind is not valid,
// reset the current selection kind to none.
Expand All @@ -437,6 +490,7 @@ global proc mayaUsdMenu_loadui() {
global proc mayaUsdMenu_unloadui() {
termCreateMenu();
termSelectMenu();
termAEShowMenu();
}

///////////////////////////////////////////////////////////////////////////////
Expand Down