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

Visualize the current edit target - breadcrumbs #33

Open
BigRoy opened this issue Dec 1, 2023 · 0 comments
Open

Visualize the current edit target - breadcrumbs #33

BigRoy opened this issue Dec 1, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@BigRoy
Copy link
Owner

BigRoy commented Dec 1, 2023

Issue

It can be tricky to visualize exactly what the current edit target is when dealing with variants and e.g. editing nested variants.

Idea

I was thinking of maybe displaying these in a "breadcrumb" like way where one could also click to go up and pop off a variant of the edit target.

image

Like that image it can also have little drop down entries to "pick" from the current stage what additional targets could be appended to the current mapping, e.g. another variant set.

Here's some quick pseudocode:

from pxr import Usd, Sdf


def get_edit_target_breadcrumbs(edit_target):
    layer = edit_target.GetLayer()
    if not edit_target.IsValid():
        return []
        
    layer_str = layer.GetDisplayName()
    
    mapping = edit_target.GetMapFunction()
    if mapping.isIdentityPathMapping:
        return [layer_str]
        
    crumbs = [layer_str]
    for source, target in mapping.sourceToTargetMap.items():
        if source == target:
            # Nothing special here?
            continue

        crumbs.append(source.pathString)
        
    return crumbs
    
    
edit_target = stage.GetEditTarget()
crumbs = get_edit_target_breadcrumbs(edit_target)
print(f"Edit Target: {' > '.join(crumbs)}")

# Targeting e.g. root layer this shows:
# Edit Target: look.usda
# Targeting the variant set `model` variant `main` on `/root` prim
# Edit Target: look.usda > /asset/geo{model=main}
# Then appending subtarget look = main
# Edit Target: look.usda > /asset/geo{model=main}{look=main}

Which in breadcrumbds could be clickable blocks like:

look.usda  >  /asset/geo  >  {model=main}  >  {look=main}
@BigRoy BigRoy added the enhancement New feature or request label Dec 1, 2023
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
None yet
Development

No branches or pull requests

1 participant