-
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-107424 - On stage AE template load/reload a file as stage source #1218
MAYA-107424 - On stage AE template load/reload a file as stage source #1218
Conversation
… as the stage source * Added debugging messages to template helpers (controlled from var). * New template helper method to deal with file path being changed from text field and file browser button. * New template helper method to refresh file path attribute. * Replace file path attribute with custom control containing: label, text field (for path), file browser button, file refresh button.
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.
There was only one minor change (to a string in the reload dialog) since my demo yesterday.
|
||
# If we have a dirty layer stack, display dialog to confirm new loading. | ||
if dirtyStack: | ||
kTitleFormat = mel.eval('getMayaUsdString("kDiscardStageEditsTitle")') |
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.
Pretty awkward that there is no way to do this from Python. Certainly getMayaUsdString() isn't doing much, and
https://git.autodesk.com/maya3d/maya/blob/master/Maya/src/OpenMaya/Commands/getPluginResource.mel
isn't doing much either... I guess we can just leave it as you have it, not a big deal.
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 looked at the MEL procs for register/get string resources and unfortunately they don't have python equivalents. But they are trivial, so I've implemented a python version of them in our plugin and now no longer need the mel.eval.
# Pop the file open dialog for user to load new usd file. | ||
title = mel.eval('getMayaUsdString("kLoadUSDFile")') | ||
okCaption = mel.eval('getMayaUsdString("kLoad")') | ||
fileFilter = mel.eval('getMayaUsdString("kAllUsdFiles")') + ' (*.usd *.usda *.usdc *.usdz );;*.usd;;*.usda;;*.usdc;;*.usdz'; |
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.
Do we have the filter tokens available in Python? e.g. UsdMayaTranslatorTokens is what we use in c++ when we need filters like this.
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 see those in the C++ code, but I don't see anywhere they are wrapped into python. I also checked the USD repo and in their python code they just use the actual strings.
… as the stage source * Created system to register/get localized strings from python. Used that in the AETemplateHelpers file.
def register(key, value): | ||
registerPluginResource('mayaUsdPlugin', key, value) | ||
|
||
def getMayaUsdString(key): | ||
return getPluginResource('mayaUsdPlugin', key) |
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.
Identical to the ones in the MEL file (of the same name).
register("kButtonYes", "Yes") | ||
register("kButtonNo", "No") | ||
register("kDiscardStageEditsTitle", "Discard Edits on ^1s's Layers") | ||
register("kDiscardStageEditsLoadMsg", "Are you sure you want to load in a new file as the stage source?\n\nAll edits on your layers in ^1s will be discarded.") | ||
register("kDiscardStageEditsReloadMsg", "Are you sure you want to reload ^1s as the stage source?\n\nAll edits on your layers (except the session layer) in ^2s will be discarded.") | ||
register("kLoadUSDFile", "Load USD File") |
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.
These are the strings that are used exclusively from python. But they can also be loaded by MEL.
def registerPluginResource(pluginId, stringId, resourceStr): | ||
'''See registerPluginResource.mel in Maya. | ||
|
||
Unfortunately there is no equivalent python version of this MEL proc | ||
so we created our own version of it here.''' | ||
|
||
fullId = 'p_%s.%s' % (pluginId, stringId) | ||
if cmds.displayString(fullId, exists=True): | ||
# Issue warning if the string is already registered. | ||
msgFormat = mel.eval('uiRes("m_registerPluginResource.kNotRegistered")') | ||
msg = cmds.format(msgFormat, stringArg=(pluginId, stringId)) | ||
cmds.warning(msg) | ||
# Replace the string's value | ||
cmds.displayString(fullId, replace=True, value=resourceStr) | ||
else: | ||
# Set the string's default value. | ||
cmds.displayString(fullId, value=resourceStr) | ||
|
||
def getPluginResource(pluginId, stringId): | ||
'''See getPluginResource.mel in Maya. | ||
|
||
Unfortunately there is no equivalent python version of this MEL proc | ||
so we created our own version of it here.''' | ||
|
||
# Form full id string. | ||
# Plugin string id's are prefixed with "p_". | ||
fullId = 'p_%s.%s' % (pluginId, stringId) | ||
if cmds.displayString(fullId, exists=True): | ||
dispStr = cmds.displayString(fullId, query=True, value=True) | ||
return dispStr | ||
else: | ||
msgFormat = mel.eval('uiRes("m_getPluginResource.kLookupFailed")') | ||
msg = cmds.format(msgFormat, stringArg=(pluginId, stringId)) | ||
cmds.error(msg) |
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.
Python ports of the MEL procs from Maya.
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.
LGTM
MAYA-107424 - On the stage AE template I'd like to load/reload a file as the stage source