Asset Plug-ins (Python)¶
Note
Python-based AssetAPI plug-ins have been deprecated, and support for them will be removed in a future release. Moving forward, for performance and stability reasons, AssetAPI plug-ins are to be written in C++.
Asset Plugins¶
-
AssetAPI.
RegisterAssetPlugin
()¶ Registers a Python Asset plug-in with the AssetAPI plug-in registry.
Deprecated: Python-based AssetAPI plug-ins have been deprecated, and support for them will be removed in a future release. Moving forward, for performance and stability reasons, AssetAPI plug-ins are to be written in C++.
Parameters: - name (
str
) – name of the plug-in to register - plugin (
AssetAPI.BaseAssetPlugin
) – instance of the Asset plug-in to register
- name (
-
class
AssetAPI.
BaseAssetPlugin
¶ Bases:
object
Base class for Python-based Asset plug-ins.
See the Katana Developer Guide (Writing Plug-ins > Asset Plug-ins) or the C++ headers in
$KATANA_ROOT/plugin_apis/include/FnAsset/
for more complete documentation.Deprecated: Python-based AssetAPI plug-ins have been deprecated, and support for them will be removed in a future release. Moving forward, for performance and stability reasons, AssetAPI plug-ins are to be written in C++. -
buildAssetId
(fields)¶ Convert from asset fields to asset id. (fields is a dict with string keys/values.)
-
checkPermissions
(assetId, context)¶
-
containsAssetId
(string)¶ Return True if input string contains a valid asset id anywhere within it.
-
createAssetAndPath
(txn, assetType, fields, args, createDirectory)¶ Create asset and optional directory path. Return asset id created.
-
createTransaction
()¶ Creates a transaction object that might be able to rollback a series of actions performed by the plugin. This function can return None if the Asset Management System does not support transactions.
-
getAssetAttributes
(assetId, scope)¶ Get metadata associated with an asset or a scoped item in the asset hierarchy. (Return dict with string keys/values.)
-
getAssetDisplayName
(assetId)¶ Produces a name for the given asset that can be used to respresent the asset in a scene graph location
-
getAssetFields
(assetId, includeDefaults)¶ Convert from asset id to a set of named string fields defining the asset. (Return dict with string keys/values.)
-
getAssetIdForScope
(assetId, scope)¶ Return the partial asset id scoped to the specified level in the asset hierarchy.
-
getAssetVersions
(assetId)¶ Return the versions and tags of this asset as a tuple of strings
-
getRelatedAssetId
(assetId, relation)¶ Return asset id that is related to input asset, given a relationship type.
-
getUniqueScenegraphLocationFromAssetId
(assetId, includeVersion=True)¶ Return a valid scenegraph location path that uniquely represents the input asset id.
-
isAssetId
(string)¶ Return True if input string represents a valid asset id.
-
postCreateAsset
(txn, assetType, fields, args)¶ Creates an asset after the creation of the files to be published. Return asset id created.
-
reset
()¶ Will be called when Katana flushes its caches, giving the plugin a chance to reset.
Note that this method will only be called if other API methods have previously been called (i.e. it won’t get called if there have been no API calls that could have resulted in caches being created).
-
resolveAllAssets
(string)¶ Replace any asset ids found in input string with resolved asset strings.
-
resolveAsset
(assetId)¶ Lookup asset id in asset system and return path (or other string) that it references.
-
resolveAssetVersion
(assetId, versionStr)¶ Return integer version that this asset id resolves to.
-
resolvePath
(string, frame)¶ Resolve env vars in input path string, then resolve asset id (if necessary) and file sequences.
-
runAssetPluginCommand
(assetId, command, commandArgs)¶
-
setAssetAttributes
(assetId, scope, attrs)¶ Set metadata associated with an asset or a scoped item in the asset hierarchy. (attrs is a dict with string keys/values.)
-
File Sequence Plugins¶
-
AssetAPI.
RegisterFileSequencePlugin
()¶ Registers a Python File Sequence plug-in with the AssetAPI plug-in registry.
Deprecated: Python-based AssetAPI plug-ins have been deprecated, and support for them will be removed in a future release. Moving forward, for performance and stability reasons, AssetAPI plug-ins are to be written in C++.
Parameters: - name (
str
) – name of the plug-in to register - plugin (
AssetAPI.BaseFileSequencePlugin
) – instance of the File Sequence plug-in to register
- name (
-
class
AssetAPI.
BaseFileSequencePlugin
¶ Bases:
object
Primary class to derive from when implementing a Python-based File Sequence plug-in.
See the Katana Developer Guide (Writing Plug-ins > Asset Plug-ins) or the C++ headers in
$KATANA_ROOT/plugin_apis/include/FnAsset/
for more complete documentation.Deprecated: Python-based AssetAPI plug-ins have been deprecated, and support for them will be removed in a future release. Moving forward, for performance and stability reasons, AssetAPI plug-ins are to be written in C++. -
buildFileSequenceString
(prefix, suffix, padding)¶ Return file sequence string built from given prefix, suffix, padding values.
-
findSequence
(fileList)¶ Return (seq, nonseq) tuple containing sequences and filepaths found in fileList. Seq should be a list of FileSequence objects, nonseq should be a list of filenames not included in any sequence.
-
getFileSequence
(seqstr)¶ Return a FileSequence object for the given seqstr.
-
isFileSequence
(seqstr)¶ Return True if seqstr is a valid file sequence.
-
-
class
AssetAPI.
BaseFileSequence
(seqstr)¶ Bases:
object
Class that constructs a file sequence object instance for a given file sequence string.
Deprecated: Python-based AssetAPI plug-ins have been deprecated, and support for them will be removed in a future release. Moving forward, for performance and stability reasons, AssetAPI plug-ins are to be written in C++. -
__init__
(seqstr)¶ Validate seqstr as valid file sequence, raise exception on error.
-
getAsString
()¶ Return file sequence as string.
-
getDirectory
()¶ Return directory portion of file sequence.
-
getFirstFrame
()¶ Return first (minimum) frame in embedded frame set, or 0 if no frame set.
-
getFrameList
()¶ Return frame set as list of integers, or empty list if no frame set.
-
getLastFrame
()¶ Return last (maximum) frame in embedded frame set, or 0 if no frame set.
-
getNearestFrames
(frame)¶ Return nearest frames (left, right) to left and right of frame. If no frame set, return (None, None).
-
getPadding
()¶ Return integer frame padding amount of file sequence.
-
getPrefix
()¶ Return prefix portion of file sequence.
-
getResolvedPath
(frame)¶ Return file sequence converted to file path at frame. If file sequence has a frame set and frame is outside range, raise exception.
-
getSuffix
()¶ Return suffix portion of file sequence.
-
hasFrame
(frame)¶ Return True if frame in embedded frame set. If no frame set, always return True.
-
hasFrameSet
()¶ Return True if file sequence has embedded frame set.
-