Asset API (C++)¶
-
namespace
Foundry
¶ -
namespace
Katana
¶ -
class
DefaultAssetPlugin
¶ - #include <FnDefaultAssetPlugin.h>
Allows the access to the currently set Asset Management System plugin.
This class can be used when a plugin (a Scenegraph Generator, for example) needs to resolve or publish assets using the Asset Management System Plugin set on the current scene (regardless if it is implemented in C++ or Python)....
Public Static Functions
-
static bool
isAssetId
(const std::string &str, bool throwOnError = false)¶ Return whether the input string represents a valid asset id.
Should parse the input string to determine whether it is a valid asset id. Should not attempt to determine whether the asset actually exists in the asset database.
- Return
- True if the string is valid asset id syntax.
- Parameters
str
-The string to test.
throwOnError
-Boolean setting whether to throw an exception on error.
-
static bool
containsAssetId
(const std::string &str, bool throwOnError = false)¶ Return whether the input string contains a valid asset id anywhere within it.
Should parse the input string to determine whether it contains a valid asset id. Should not attempt to determine whether any asset ids found in the string actually exist in the asset database.
- Return
- True if the string contains a valid asset id.
- Parameters
str
-The string to test.
throwOnError
-Boolean setting whether to throw an exception on error.
-
static std::string
resolveAsset
(const std::string &assetId, bool throwOnError = false)¶ Lookup asset id in asset system and return path (or other string) that it references.
- Return
- The resolved asset string.
- Parameters
assetId
-Asset id to resolve.
throwOnError
-Boolean setting whether to throw an exception on error.
-
static std::string
resolveAllAssets
(const std::string &inputString, bool throwOnError = false)¶ Replace any asset ids found in the given input string with resolved asset strings.
- Return
- The string with all asset ids replaced with resolved asset strings.
- Parameters
inputString
-The string to be searched for asset ids.
throwOnError
-Boolean setting whether to throw an exception on error.
-
static std::string
resolvePath
(const std::string &path, int frame, bool throwOnError = false)¶ Resolve env vars in input path string, then resolve asset ids and file sequences.
File sequence will most likely be resolved using default file sequence plugin from host. This is a good candidate for some base functionality in the C++ wrappers on the plugin side.
- Return
- The resolved path string.
- Parameters
path
-Input path string to resolve.
frame
-Frame number to resolve file sequences with.
throwOnError
-Boolean setting whether to throw an exception on error.
-
static std::string
getUniqueScenegraphLocationFromAssetId
(const std::string &assetId, bool includeVersion, bool throwOnError = false)¶
-
static std::string
getRelatedAssetId
(const std::string &assetId, const std::string &relation, bool throwOnError = false)¶
-
static bool
getAssetAttributes
(const std::string &assetId, const std::string &scope, std::map<std::string, std::string> &attributesMap, bool throwOnError = false)¶ Gets metadata associated with an asset or a scoped item in the asset hierarchy.
- Return
- Parameters
assetId
-The id of the asset to search for metadata.
scope
-A scoped item name.
attributes
-A map to be filled with the metadata attributes of the given asset.
throwOnError
-Boolean setting whether to throw an exception on error.
-
static bool
checkPermissions
(const std::string &assetId, const std::map<std::string, std::string> &context, bool throwOnError = false)¶ Returns whether permissions for the given asset id are valid in the given context.
- Return
- Parameters
assetId
-The id of the asset to check permission for.
context
-throwOnError
-Boolean setting whether to throw an exception on error.
-
static std::string
resolveAssetVersion
(const std::string &assetId, const std::string &versionTag = std::string(), bool throwOnError = false)¶ Returns the version for a given asset id. If it is a partial asset id (which does not have a version) then an empty string is returned.
- Return
- String with the integer version number that this asset id resolves to, or an empty string if an error occurs.
- Parameters
assetId
-The asset id to resolve.
throwOnError
-Boolean setting whether to throw an exception on error.
-
static std::string
getAssetDisplayName
(const std::string &assetId, bool throwOnError = false)¶ Returns a name suitable for displaying to the user for the given asset id.
- Return
- The display name of the given asset.
- Parameters
assetId
-The asset id to look for display name.
throwOnError
-Boolean setting whether to throw an exception on error.
-
static bool
getAssetVersions
(const std::string &assetId, std::vector<std::string> &versions, bool throwOnError = false)¶ Gets a list of all the available versions of the given asset.
- Return
- True on success.
- Parameters
assetId
-The asset id to look for available versions.
versions
-The vector to be filled with the available versions of the given asset.
throwOnError
-Boolean setting whether to throw an exception on error.
-
static bool
getAssetFields
(const std::string &assetId, bool includeDefaults, std::map<std::string, std::string> &returnFields, bool throwOnError = false)¶ Convert from asset id to a set of named string fields defining the asset.
The minimum set of fields are “name” and “version”. Other fields are preserved but ignored by Katana.
- Return
- True on success.
- Parameters
assetId
-Input asset id.
includeDefaults
-If true, return the full set of fields for this asset system, including defaults not specified in the asset id. If false, return only the fields specified in the asset id.
returnFields
-A map to be filled with the asset fields.
throwOnError
-Boolean setting whether to throw an exception on error.
-
static std::string
buildAssetId
(const std::map<std::string, std::string> &fields, bool throwOnError = false)¶ Builds and return a new asset id using the given fields.
- Return
- The new asset id, on success. Otherwise an empty string.
- Parameters
fields
-A map of fields used to build the new asset id.
throwOnError
-Boolean setting whether to throw an exception on error.
-
static std::string
getAssetIdForScope
(const std::string &assetId, const std::string &scope, bool throwOnError = false)¶ Gets an asset id scoped to the specified level in the asset hierarchy.
Should return a more general asset reference to the given asset id. For instance, if scope is “name”, returns an asset id that doesn’t include a specific version number. This may not make sense in some asset systems, in which case, return the input asset id.
- Return
- A string containing the result asset id.
- Parameters
assetId
-The input asset id.
scope
-A string specifying scope for result asset id, such as “name” or “version”.
-
static bool
-
class
-
namespace