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
class AssetAPI.BaseAssetPlugin

Bases: object

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++.
__dict__ = dict_proxy({'resolveAsset': <function resolveAsset at 0x7f0e28ff6ed8>, '__module__': 'AssetAPI.BaseAssetPlugin', 'resolveAssetVersion': <function resolveAssetVersion at 0x7f0e28ffa0c8>, 'getAssetAttributes': <function getAssetAttributes at 0x7f0e28ffa398>, 'containsAssetId': <function containsAssetId at 0x7f0e28ff6d70>, 'createAssetAndPath': <function createAssetAndPath at 0x7f0e28ffa500>, 'getAssetIdForScope': <function getAssetIdForScope at 0x7f0e28ffa488>, 'getAssetVersions': <function getAssetVersions at 0x7f0e28ffa1b8>, 'resolveAllAssets': <function resolveAllAssets at 0x7f0e28ff6f50>, '__dict__': <attribute '__dict__' of 'BaseAssetPlugin' objects>, '__weakref__': <attribute '__weakref__' of 'BaseAssetPlugin' objects>, 'reset': <function reset at 0x7f0e28ff6c80>, 'postCreateAsset': <function postCreateAsset at 0x7f0e28ffa578>, 'resolvePath': <function resolvePath at 0x7f0e28ffa050>, 'getUniqueScenegraphLocationFromAssetId': <function getUniqueScenegraphLocationFromAssetId at 0x7f0e28ffa140>, 'runAssetPluginCommand': <function runAssetPluginCommand at 0x7f0e28ff6e60>, 'setAssetAttributes': <function setAssetAttributes at 0x7f0e28ffa410>, 'getRelatedAssetId': <function getRelatedAssetId at 0x7f0e28ffa230>, 'getAssetDisplayName': <function getAssetDisplayName at 0x7f0e28ffa668>, 'buildAssetId': <function buildAssetId at 0x7f0e28ffa320>, 'createTransaction': <function createTransaction at 0x7f0e28ffa5f0>, 'checkPermissions': <function checkPermissions at 0x7f0e28ff6de8>, '__doc__': '\n @deprecated: Python-based AssetAPI plug-ins have been deprecated, and\n support for them will be removed in a future release. Moving forward,\n for performance and stability reasons, AssetAPI plug-ins are to be\n written in C++.\n ', 'isAssetId': <function isAssetId at 0x7f0e28ff6cf8>, 'getAssetFields': <function getAssetFields at 0x7f0e28ffa2a8>})
__module__ = 'AssetAPI.BaseAssetPlugin'
__weakref__

list of weak references to the object (if defined)

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:
class AssetAPI.BaseFileSequencePlugin

Bases: object

Primary class to derive from when implementing a File Sequence plug-in.

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++.
__dict__ = dict_proxy({'buildFileSequenceString': <function buildFileSequenceString at 0x7f0e28ffa8c0>, '__module__': 'AssetAPI.BaseFileSeqPlugin', '__dict__': <attribute '__dict__' of 'BaseFileSequencePlugin' objects>, 'isFileSequence': <function isFileSequence at 0x7f0e28ffa848>, '__weakref__': <attribute '__weakref__' of 'BaseFileSequencePlugin' objects>, 'findSequence': <function findSequence at 0x7f0e28ffa938>, 'getFileSequence': <function getFileSequence at 0x7f0e28ffa7d0>, '__doc__': '\n Primary class to derive from when implementing a File Sequence plug-in.\n\n @deprecated: Python-based AssetAPI plug-ins have been deprecated, and\n support for them will be removed in a future release. Moving forward,\n for performance and stability reasons, AssetAPI plug-ins are to be\n written in C++.\n '})
__module__ = 'AssetAPI.BaseFileSeqPlugin'
__weakref__

list of weak references to the object (if defined)

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++.
__dict__ = dict_proxy({'getDirectory': <function getDirectory at 0x7f0e28ffaaa0>, '__module__': 'AssetAPI.BaseFileSeqPlugin', 'getNearestFrames': <function getNearestFrames at 0x7f0e28ffaed8>, 'getLastFrame': <function getLastFrame at 0x7f0e28ffae60>, 'getSuffix': <function getSuffix at 0x7f0e28ffab90>, 'getPadding': <function getPadding at 0x7f0e28ffac08>, 'getResolvedPath': <function getResolvedPath at 0x7f0e28ffac80>, 'hasFrame': <function hasFrame at 0x7f0e28ffad70>, 'getPrefix': <function getPrefix at 0x7f0e28ffab18>, '__weakref__': <attribute '__weakref__' of 'BaseFileSequence' objects>, 'getAsString': <function getAsString at 0x7f0e28ffaa28>, '__dict__': <attribute '__dict__' of 'BaseFileSequence' objects>, 'hasFrameSet': <function hasFrameSet at 0x7f0e28ffacf8>, 'getFrameList': <function getFrameList at 0x7f0e28ffaf50>, 'getFirstFrame': <function getFirstFrame at 0x7f0e28ffade8>, '__doc__': '\n Class that constructs a file sequence object instance for a given file sequence string.\n\n @deprecated: Python-based AssetAPI plug-ins have been deprecated, and\n support for them will be removed in a future release. Moving forward,\n for performance and stability reasons, AssetAPI plug-ins are to be\n written in C++.\n ', '__init__': <function __init__ at 0x7f0e28ffa9b0>})
__init__(seqstr)

Validate seqstr as valid file sequence, raise exception on error.

__module__ = 'AssetAPI.BaseFileSeqPlugin'
__weakref__

list of weak references to the object (if defined)

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.