Skip to content

resolveAssetVersion

Peter Shinners edited this page Apr 20, 2021 · 6 revisions
void  resolveAssetVersion(
    const std::string& assetId,
    std::string& ret, 
    const std::string& versionStr = std::string()
)

If the given assetId is valid, find a specific versionStr to reference. The versionStr is optional, and if empty, return the name of the version assetId already refers to.

Copy a of the individual version name or number should be copied into ret as a string. It should not be a complete assetId or file path. The return ret should be assigned to an empty string if any of the arguments are unknown or invalid.

The versionStr argument isn't required to be a numeric version number. It can be passed as a label or definition like "approved" or "latest".

If versionStr is an empty string, this should check if the assetId defines a version and return that.

If the resulting results in a numeric version value, it will need to be converted into a string for the ret argument. That can be done with an itoa style function or passing through a stringstream like:

    std::stringstream writer;
    writer << numeric_version;
    writer >> ret;

This is called from the Importomatic after the user selects one of the versions generated by getAssetVersions.

Katana also uses this call during the look file resolver.

The optional example Casting Sheet plugin also has examples of calling this method.

Katana can expose this value as a custom $VERSION variable that is substituted into the output path of a Render node.