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-125954] Expose command/interface to indicate which variant to select on import of USD #2685

Closed
tanant opened this issue Oct 26, 2022 Discussed in #2214 · 8 comments
Closed
Labels
enhancement New feature or request

Comments

@tanant
Copy link
Contributor

tanant commented Oct 26, 2022

Originally discussed in #2214

Opening new issue to capture the work. On import, the UI provides a way to select the particular variants desired, and it'd be good to provide a similar capability for the file importer so that loads and imports can pick correct variant without needing to open the UI up.

Note - this is specifically for the pathway where the USD stage is imported into the maya data model (i.e. translated to native maya, not the other pathway where we keep it as USD).

Originally posted by jcoelho88 March 23, 2022
Hello,

I want to be able to import my USD assets with variant selection via python.

When importing with the import dialog there is a option to open a hierarchy view and select the variants on what ever prim you want.

The command pops up in the script editor when its ran but I do not see how any of the options chosen in the Hierarchy view is being applied.

Currently an import command I use could look like this.

cmds.file(
            assetusd_path, i=True, type='USD Import', ignoreVersion=True,
            renameAll=True, mergeNamespacesOnClash=False, namespace=namespace,
            options=";shadingMode=[[none,default]];preferredMaterial=none;primPath=/;readAnimData=0;"
                    "useCustomFrameRange=0;startTime=0;endTime=0;importUSDZTextures=0",
            preserveReferences=True, importFrameRate=True, importTimeRange='override',
        )

How do I include the options for variant selection on specific prims via the python import command?

Any help would be appreciated.

Cheers,

Jason Coelho

@tanant tanant added the enhancement New feature or request label Oct 26, 2022
@tanant
Copy link
Contributor Author

tanant commented Oct 27, 2022

admin action - internally logged as MAYA-125954

@tanant tanant changed the title Expose command/interface to indicate which variant to select on import of USD [MAYA-125954] Expose command/interface to indicate which variant to select on import of USD Oct 31, 2022
@erikstantoncarlson
Copy link

To add to this, I imagine there could be a variants keyword arg which could be a dictionary such as

{
    '{prim_path}': {
        '{variant_set}': '{variant}'
    }
}

Example:

variants = {
    '/asset/geo': {
        'model': 'damaged',
        'look': 'damaged'
    },
    '/asset/hair': {
        'hair': 'wet'
    }
}
cmds.file(asset_usd_path, i=True, type='USD Import', options="variants={variants};...".format(variants), ...)

Not completely sure how options would represent a dictionary value since it's all stringified, but I hope you get the idea.

@tanant
Copy link
Contributor Author

tanant commented Dec 1, 2022

Would there be a major benefit using a dict over a flat repeatable tuple of (prim_path, variant_set, variant)? e.g. [('/asset/geo', 'look', 'damaged'), ('/asset/geo', 'model', 'damaged'), ('/asset/hair', 'hair', 'wet')]

@erikstantoncarlson
Copy link

I think your example is just as valid.

@dolivares-spinvfx
Copy link

The tuple approach may be better than a dict to maintain order for nested variant sets (at least in python 2.7)

usd primspec paths specify variants like this:
/path/to/prim{variant_set=variant}continuing/path/to/a/child/prim{another_variant_set=variant}etc/etc

@jcoelho88
Copy link

@tanant It looks like this has been addressed in Maya-usd 0.21.0

USD import command support prim variants #2703

Add a new -primVariant (-pv) flag to the mayaUSDimport command.
Takes three argument: prim path, variant name, variant selection.
Can be repeated.
Extended an existing unit test to test it.

I'll have to test it after updating to the latest plugin.

@jcoelho88
Copy link

So I was able to test the primVariants option and it did work as advertised.

Here is a snippet of how it was run, using Maya 2023 and Maya-usd 0.21.0

primVariants=[("/prp_barrel_master", "geom", "small"), ("/prp_barrel_master", "look", "default")]
cmds.mayaUSDImport(
    file=assetusd_path, primPath="/", primVariant=primVariants,
    shadingMode=[["useRegistry","UsdPreviewSurface"],["displayColor","standardSurface"]],
)

This will make certain workflows more viable on my end, glad this made it in.

Cheers,

Jason Coelho

@santosd
Copy link
Collaborator

santosd commented Jan 5, 2023

Nice! Thank you for validating that @jcoelho88 I will go ahead and close this ticket out for the time being.

@santosd santosd closed this as completed Jan 5, 2023
@neilh-adsk neilh-adsk moved this to Done in maya-usd Nov 6, 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
Archived in project
Development

No branches or pull requests

5 participants