-
Notifications
You must be signed in to change notification settings - Fork 221
Add expanded assembly subcomponent support for pxrUsdReferenceAssembly #4644
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
Merged
seando-adsk
merged 2 commits into
Autodesk:dev
from
dj-mcg:pr/expanded-assembly-subcomponents
Jun 29, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 0 additions & 93 deletions
93
plugin/pxr/maya/lib/usdMaya/AEpxrUsdProxyShapeTemplate.mel
This file was deleted.
Oops, something went wrong.
199 changes: 199 additions & 0 deletions
199
plugin/pxr/maya/lib/usdMaya/AEpxrUsdProxyShapeTemplate.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,199 @@ | ||
| # | ||
| # Copyright 2026 Pixar | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| from pxr import UsdMaya | ||
|
|
||
| from maya import cmds | ||
| from maya import mel | ||
|
|
||
| import functools | ||
|
|
||
|
|
||
| # ======================================================================== | ||
| # VARIANT SETS | ||
| # ======================================================================== | ||
|
|
||
| def _GetVariantSetInfoFromNode(node, variantSetName): | ||
| '''Returns (override, settable) for the variantSetName on node.''' | ||
| variantAttrName = 'usdVariantSet_%s' % variantSetName | ||
| override = '' | ||
| settable = True | ||
| if cmds.attributeQuery(variantAttrName, node=node, exists=True): | ||
| variantSetPlgVal = cmds.getAttr('%s.%s' % (node, variantAttrName)) | ||
| if variantSetPlgVal: | ||
| override = variantSetPlgVal | ||
| settable = cmds.getAttr('%s.%s' % (node, variantAttrName), settable=True) | ||
| return override, settable | ||
|
|
||
|
|
||
| def _variantSets_changeCommand(unused, omg, node, variantSetName): | ||
| val = cmds.optionMenuGrp(omg, q=True, value=True) | ||
|
|
||
| AuthorVariantSelectionFromAE(node, variantSetName, val) | ||
|
|
||
| # Update the resolved variant selection label | ||
| resolvedVariant = '' | ||
| usdPrim = UsdMaya.GetPrim(node) | ||
| if usdPrim: | ||
| variantSet = usdPrim.GetVariantSet(variantSetName) | ||
| if variantSet: | ||
| resolvedVariant = variantSet.GetVariantSelection() | ||
| cmds.optionMenuGrp(omg, edit=True, extraLabel=resolvedVariant) | ||
|
|
||
|
|
||
| def AuthorVariantSelectionFromAE(node, variantSetName, variantSelection): | ||
| variantAttr = 'usdVariantSet_%s' % variantSetName | ||
| if not cmds.attributeQuery(variantAttr, node=node, exists=True): | ||
| cmds.addAttr(node, ln=variantAttr, dt='string', internalSet=True) | ||
| cmds.setAttr('%s.%s' % (node, variantAttr), variantSelection, type='string') | ||
|
|
||
|
|
||
| def variantSets_Replace(nodeAttr, new): | ||
| origParent = cmds.setParent(q=True) | ||
|
|
||
| frameLayoutName = 'AEpxrUsdProxyShapeTemplate_variantSets_Layout' | ||
| if new: | ||
| cmds.frameLayout(frameLayoutName, label='VariantSets', collapse=False) | ||
| else: | ||
| cmds.setParent(frameLayoutName) | ||
|
|
||
| # Remove existing children of layout | ||
| children = cmds.frameLayout(frameLayoutName, q=True, childArray=True) | ||
| if children: | ||
| for child in children: | ||
| cmds.deleteUI(child) | ||
|
|
||
| node = nodeAttr.split('.', 1)[0] | ||
| usdPrim = UsdMaya.GetPrim(node) | ||
| if usdPrim: | ||
| for variantSetName in usdPrim.GetVariantSets().GetNames(): | ||
| usdVariantSet = usdPrim.GetVariantSet(variantSetName) | ||
| variantResolved = usdVariantSet.GetVariantSelection() | ||
| variantSetChoices = [''] + usdVariantSet.GetVariantNames() | ||
| variantOverride, variantSettable = _GetVariantSetInfoFromNode( | ||
| node, variantSetName) | ||
|
|
||
| omg = cmds.optionMenuGrp( | ||
| label=variantSetName, | ||
| enable=variantSettable, | ||
| extraLabel=variantResolved) | ||
| for choice in variantSetChoices: | ||
| cmds.menuItem(label=choice) | ||
|
|
||
| try: | ||
| cmds.optionMenuGrp(omg, e=True, value=variantOverride) | ||
| except RuntimeError: | ||
| cmds.warning('Invalid choice %r for %r' | ||
| % (variantOverride, variantSetName)) | ||
|
|
||
| cmds.optionMenuGrp(omg, e=True, | ||
| changeCommand=functools.partial( | ||
| _variantSets_changeCommand, | ||
| omg=omg, node=node, variantSetName=variantSetName)) | ||
|
|
||
| cmds.setParent(origParent) | ||
|
|
||
|
|
||
| def variantSets_Replace_new(nodeAttr): | ||
| variantSets_Replace(nodeAttr, new=True) | ||
|
|
||
| def variantSets_Replace_replace(nodeAttr): | ||
| variantSets_Replace(nodeAttr, new=False) | ||
|
|
||
|
|
||
| # ======================================================================== | ||
| # FILE PATH | ||
| # ======================================================================== | ||
|
|
||
| def filePath_Replace(nodeAttr, new): | ||
| if new: | ||
| cmds.setUITemplate('attributeEditorTemplate', pushTemplate=True) | ||
| cmds.rowLayout(numberOfColumns=3) | ||
| cmds.text(label='File Path') | ||
| cmds.textField('pxrUsdProxyShape_usdFilePathField') | ||
| cmds.symbolButton('pxrUsdProxyShape_usdFileBrowserButton', | ||
| image='navButtonBrowse.xpm') | ||
| cmds.setParent('..') | ||
| cmds.setUITemplate(popTemplate=True) | ||
|
|
||
| def _showFileBrowser(*args): | ||
| filePaths = cmds.fileDialog2( | ||
| caption="Specify USD File", | ||
| fileFilter="USD Files (*.usd*) (*.usd*);;Alembic Files (*.abc)", | ||
| fileMode=1) | ||
| if filePaths: | ||
| cmds.setAttr(nodeAttr, filePaths[0], type='string') | ||
| cmds.button('pxrUsdProxyShape_usdFileBrowserButton', edit=True, | ||
| command=_showFileBrowser) | ||
|
|
||
| cmds.evalDeferred(functools.partial( | ||
| cmds.connectControl, 'pxrUsdProxyShape_usdFilePathField', nodeAttr)) | ||
|
|
||
|
|
||
| def filePath_Replace_new(nodeAttr): | ||
| filePath_Replace(nodeAttr, new=True) | ||
|
|
||
| def filePath_Replace_replace(nodeAttr): | ||
| filePath_Replace(nodeAttr, new=False) | ||
|
|
||
|
|
||
| # ======================================================================== | ||
| # EDITOR TEMPLATE | ||
| # ======================================================================== | ||
|
|
||
| def editorTemplate(nodeName): | ||
| cmds.editorTemplate(beginScrollLayout=True) | ||
|
|
||
| isSubcomponent = UsdMaya.IsSubcomponentProxy(nodeName) | ||
|
|
||
| cmds.editorTemplate(beginLayout='USD', collapse=False) | ||
| cmds.editorTemplate( | ||
| 'filePath', | ||
| callCustom=[filePath_Replace_new, filePath_Replace_replace]) | ||
| cmds.editorTemplate('primPath', addControl=True) | ||
| cmds.editorTemplate('excludePrimPaths', addControl=True) | ||
| cmds.editorTemplate('variantKey', addControl=True) | ||
| cmds.editorTemplate('complexity', addControl=True) | ||
| cmds.editorTemplate('drawRenderPurpose', addControl=True) | ||
| cmds.editorTemplate('drawProxyPurpose', addControl=True) | ||
| cmds.editorTemplate('drawGuidePurpose', addControl=True) | ||
| cmds.editorTemplate(endLayout=True) | ||
|
|
||
| if isSubcomponent: | ||
| cmds.editorTemplate(beginLayout='Variant Sets', collapse=False) | ||
| cmds.editorTemplate( | ||
| '', | ||
| callCustom=[variantSets_Replace_new, variantSets_Replace_replace]) | ||
| cmds.editorTemplate(endLayout=True) | ||
|
|
||
| mel.eval('AEsurfaceShapeTemplate "%s"' % nodeName) | ||
| cmds.editorTemplate(addExtraControls=True) | ||
|
|
||
| cmds.editorTemplate(endScrollLayout=True) | ||
|
|
||
|
|
||
| # ======================================================================== | ||
| # MEL STUBS | ||
| # ======================================================================== | ||
|
|
||
| def addMelFunctionStubs(): | ||
| '''Create MEL proc that delegates to Python for the AE template.''' | ||
| mel.eval(''' | ||
| global proc AEpxrUsdProxyShapeTemplate( string $nodeName ) | ||
| { | ||
| python("AEpxrUsdProxyShapeTemplate.editorTemplate('"+$nodeName+"')"); | ||
| } | ||
| ''') |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.