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

Allow to set the default prim for the stage through the UI #3335

Closed
BigRoy opened this issue Sep 19, 2023 · 12 comments
Closed

Allow to set the default prim for the stage through the UI #3335

BigRoy opened this issue Sep 19, 2023 · 12 comments
Labels
enhancement New feature or request

Comments

@BigRoy
Copy link
Contributor

BigRoy commented Sep 19, 2023

Is your feature request related to a problem? Please describe.

I couldn't find a way through the Maya UI to set the default prim of a stage.

Describe the solution you'd like

It'd be great if the UI exposes a way to manage the default prim for a USD stage in a mayaUsdProxy. (So that one can manage the USD layers like that)

Similarly, I'd expect the USD Export settings for Export Selection to also allow to define a default prim in the output - but I suppose a chaser could solve that in that case.

Describe alternatives you've considered

As an alternative I have this example Python snippet to set the default prim:

from maya import cmds
import mayaUsd.ufe

for path in cmds.ls(selection=True, ufeObjects=True, long=True):
    prim = mayaUsd.ufe.ufePathToPrim(path)
    if prim and not prim.IsPseudoRoot():
        stage = prim.GetStage()
        root_layer = stage.GetRootLayer()
        
        proxy_node, prim_path = path.split(",", 1)
        print(f"Setting default prim for {proxy_node} to {prim_path}")
        
        root_layer.defaultPrim = str(prim.GetPath())
        break
@BigRoy BigRoy added the enhancement New feature or request label Sep 19, 2023
@wallworm
Copy link
Collaborator

You are in luck. We are working on support for setting the default prim for a USD stage in a mayaUsdProxy right now. We are also adding support to choose a prim path when adding a reference which will improve the workflows with referencing in general but also accommodate referencing USD files that don't specify a default prim. As for the exporter, the team and I will discuss.

@scottrenaud
Copy link

Hey @BigRoy, we'd love to get your feedback on some designs!

  1. Setting the default prim in AE/Outliner
  • via Attribute Editor, only root prims would be listed
  • via Outliner, only on root prims
  • able to clear
  • restrictions: we need to target the root layer to set default prim

Setting_the_default_prim

  1. Viewing the default prim when referencing, and selecting prim path
  • when a default prim exists
    default_prim_exists

  • when a default prim doesn't exist (we continue to default the first root prim for the user, they can change it)
    No_default_prim

  1. Setting the default prim on Export
  • works similarly as the dropdown in the AE
  • considers the root prim field if specified

Setting_default_prim_on_export

Any concerns with what you're seeing here?
Anything in particular you like or dislike or think we should change?
Anything missing?

Thanks!
Scott

@BigRoy
Copy link
Contributor Author

BigRoy commented Oct 30, 2023

Thanks Scott - these are all looking really nice.

Some thoughts that popped up:

Referencing with default prim

  • The text field when the selected prim is the default prim it kind of shows it greyed out - I wonder if that feels right since it makes it feel somewhat as if you cannot change it even though you can override it.
    • I wonder if the label reads clearer to the user if it says "Use default prim: pSphere1" instead of pSphere1 (default) since the first one hints more that the setting is "Use default prim" instead of saying use "pSphere1 (which happens to be the default)" which makes quite the difference if the USD file itself in the future were to set a different default prim.
    • Whenever you use the default prim; what does that do behind the scenes? Does it just specify no explicit default prim on referencing? So that if you'd swap the reference with another USD file that has a different default prim it takes that default one instead?
  • Once a reference was made, how do I change the default prim if I noticed I loaded the wrong one? Can I right click on the node with the references, and "Change default prim" per reference made in the current edit layer - showing basically the same select default prim UI?
  • What happens if I set the default prim - and then delete the prim? Does it just unset it? And what if I move the prim?

Exporting default prim

  • On Export Selected - does it correctly filter to only selected roots?

@scottrenaud
Copy link

Hey @BigRoy,

Thanks for the quick response!

Referencing with default prim

  • The default prim appears as placeholder text and the field would be enabled. We don't show it in the gif but as soon as you click into the field and start typing to override the prim path the placeholder would disappear. We’ll have to see how this tests/if there’s a more intuitive approach, also good point on the text! We’d have a tooltip that would explain this, but the less we can rely on that the better.
  • Yep the idea is that leaving it blank/default would make an implicit reference, not explicit, so if the default prim changes in the file, any existing references to it will get the update
  • We don't yet have the ability to change the prim path of an existing reference through the UI, would love to get more control over the references overall, and it’s been a topic of discussion, so tbd!
  • Due to how restrictions work, default prim would be considered a stronger opinion on the root layer, so it’ll prevent deleting the prim from its sublayer (where it was defined). In order to do this you would have to clear the default prim, then delete the prim.

Exporting default prim

  • That's the idea, export selection would only take the selected objects and display the top-levels of that selection as options in the default prim dropdown. However, at the moment it seems that export selection is also grabbing the selection’s ancestors, all the way up the tree, unless you script it using a parameter that's available. So looking at the example below, if I selected chair, currently export selection (through the UI) would also include its parents (kitchen and table_set), and "kitchen" would find itself in the default prim dropdown. Whereas you would only expect to see "chair", right?

ex:
kitchen
  table_set
    chair  <- selected for Export Selection

Cheers,
Scott

@BigRoy
Copy link
Contributor Author

BigRoy commented Oct 31, 2023

Thanks Scott, that all sounds great!


Due to how restrictions work, default prim would be considered a stronger opinion on the root layer, so it’ll prevent deleting the prim from its sublayer (where it was defined). In order to do this you would have to clear the default prim, then delete the prim.

This would have to at least report a useful error to the end user as to why it can't be deleted.

However, at the moment it seems that export selection is also grabbing the selection’s ancestors, all the way up the tree, unless you script it using a parameter that's available.

Ha, I was just looking for that "Export Roots" option in the UI - did appear to be missing indeed.

So looking at the example below, if I selected chair, currently export selection (through the UI) would also include its parents (kitchen and table_set), and "kitchen" would find itself in the default prim dropdown. Whereas you would only expect to see "chair", right?

Well I'd keep that behind an export flag - so that the user can e.g. say "Export Selection" and by default include ancestor paths (which I believe for most exporters is the default behavior, at least from Maya) and then have an option in the UI to export the selection as roots instead - which could be labeled anything from "Export selected as root" or "Exclude ancestors" (or reverse by default have "Include parents" enabled). At least using terminology maya users are familiar with.

Whenever that option would be toggled then the default prims list should update along I suppose.

I always feel from a user perspective the AnimBot tooltips are incredibly nice. It would be epic if the "Include parent hierarchy" option would e.g. show an animated gif as tooltip of the difference in output paths or alike.

@scottrenaud
Copy link

Agreed, thanks a bunch @BigRoy!

@neilh-adsk neilh-adsk moved this to Needs triage in maya-usd Nov 6, 2023
@maya-usd-git-sync
Copy link

Issue synced internally to EMSUSD-816

@BigRoy
Copy link
Contributor Author

BigRoy commented Nov 16, 2023

@scottrenaud Just wanted to add that it'd be nice if in a way it'd be good to visualize and edit what is the defaultPrim per layer on the stage - this could e.g. be by visualizing what the default prim is on the current edit layer, etc. but we're sometimes exporting individual layers from a mayaUsdProxyShape (e.g. a look assignment layer) as a single contribution to be referenced into a USD asset and it'd be great for that layer to have defined its default prim.

So in short, the remark is that it isn't necessarily about setting the default prim for the USD stage (root layer) but also goes for being able to set it for a particular layer in the proxy.

What do you think?

@scottrenaud
Copy link

Yep it's a good idea @BigRoy, the team discussed it not too long ago, so it's nice to have your validation!

@BigRoy
Copy link
Contributor Author

BigRoy commented Nov 23, 2023

So Maya 2024.2 with Maya USD 0.26.0 installed now exposes a "Set default prim" on the Maya USD Proxy Shape. Thanks, nice work!

Unfortunately it does not highlight or visualize which prim is the default prim - except for clicking it again it then showing a "Clear default prim" option which for artists might still make it hard to track?

image

A little overlay over the type icon in the outliner might help? Or maybe a color change of the blue line in front of it? Or is the idea that that layer data just isn't as crucial to require highlighting in the outliner?
I did notice it is visualized in the attribute editor on the stage and editable as well - that's actually really nice! Thanks.

image


As per my request here I noticed it's not possible to set the default prim of a sublayer:

# Error: Cannot set default prim. The stage default prim metadata can only be modified when the root layer [lala.usda] is targeted.
# # Traceback (most recent call last):
# #   File "C:\Program Files\Autodesk\Maya2024\Python\lib\site-packages\maya\internal\ufeSupport\ufeCmdWrapper.py", line 32, in doIt
# #     self.ufeCmd.execute()
# # RuntimeError: Cannot set default prim. The stage default prim metadata can only be modified when the root layer [lala.usda] is targeted.

Which I suppose usually makes sense but as per that comment we might want a "look" layer we're editing in Maya to end up in a Variant Set of an asset. I'm currently not sure how to manage that workflow in Maya without also requiring to define the variant set directly embedded into the layer.

How about an option that if a user does that through the UI on a different edit target that they would get a prompt instead that says:

----------------------------------------------------------------------
| Apply in root layer: root.usd | Apply in sublayer: layer.usd |  
----------------------------------------------------------------------

Which could then also offer a little information about the differences? However, once you're able to set it in a layer the question then becomes where do we visualize that and how could the user unset it? :)

I can imagine at least a "Apply in root layer" prompt could still help having someone to switch, set it, and switch back?

Anyway, since a variant set can't layer in its own sublayers (or can it?) it'd need to be a reference inside the variant set on e.g. the root default prim, that reference itself should then also supply a default prim which would need to be on that layer.

Any tips workflow wise to deal with this? Is the need for default prim on the a sublayer invalid?


Side note:

If I have sublayer that defines a default prim but the composition of sublayers that e.g. that file adds do not have that default prim (thus it's missing) Maya doesn't show that the default prim is still set (and is maybe? invalid).

image

It could be worth still displaying the non-existing default prim in the Attribute Editor, but maybe in italics or alike or with a (missing prim) suffix on the label in the dropdown.


Note that it seems that Export Selected (from regular maya geometry) still does not provide any settings for setting the default primitive in the UI for as far as I can see.

@scottrenaud
Copy link

Unfortunately it does not highlight or visualize which prim is the default prim - except for clicking it again it then showing a "Clear default prim" option which for artists might still make it hard to track?

I agree at a glance it’s not clear, and a visual indicator would help. 
As you suspected, we’re not totally convinced that it’s crucial enough for artists given it’s kind of technical and that this isn’t the only way to view/set it.
Was thinking we could keep our eye on this one and discuss further with the team.
Curious, do you think artists will need to "track" default prim frequently?

As per my request #3335 (comment) I noticed it's not possible to set the default prim of a sublayer

Nope, we don't yet have the ability to set default prim on sublayers.
Viewing and editing layer metadata (including default prim) is something that is being discussed, so TBD.

Would users want to set the default prim on a sublayer? 
I could see this possibly being useful if an artist works on an asset(s) in context (ex: modelling a slide asset in context of a park) and wants to ensure default prim is set without having to open a new stage to do it. However one can hope that automations (if done well) could free artists from caring about this detail.
As for the variant workflow you’re mentioning, unfortunately variant authoring isn’t something we can do in Maya.
Do you think you could send us an example file(s) of your scenario and we could check it out?

If I have sublayer that defines a default prim but the composition of sublayers that e.g. that file adds do not have that default prim (thus it's missing) Maya doesn't show that the default prim is still set (and is maybe? invalid).

That's right, when a default prim is deemed invalid after composition we display the empty value in the dropdown.
It’s a good idea to make it clear that there is one actually set even though it’s not being resolved. Might avoid cases where the user thinks they need to set one (if they had layers muted for example).

Note that it seems that Export Selected (from regular maya geometry) still does not provide any settings for setting the default primitive in the UI for as far as I can see.

This one isn’t ready yet.

Thanks again @BigRoy !

@barbalt
Copy link
Collaborator

barbalt commented May 2, 2024

Closing this issue as this feature has been implemented

@barbalt barbalt closed this as completed May 2, 2024
@github-project-automation github-project-automation bot moved this from Needs triage to Done in maya-usd May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Status: Done
Development

No branches or pull requests

4 participants