Asset Plug-ins (Python)

Asset Plugins

AssetAPI.RegisterAssetPlugin()

Registers a new asset plugin in to the Katana plugin registry. Takes the name of the plugin as the first argument and an instance of it as the second.

class AssetAPI.BaseAssetPlugin

Bases: object

__dict__ = dict_proxy({'resolveAsset': <function resolveAsset at 0x15a5398>, '__module__': 'AssetAPI.BaseAssetPlugin', 'resolveAssetVersion': <function resolveAssetVersion at 0x15a5500>, 'getAssetAttributes': <function getAssetAttributes at 0x15a57d0>, 'containsAssetId': <function containsAssetId at 0x15a5230>, 'createAssetAndPath': <function createAssetAndPath at 0x15a5938>, 'getAssetIdForScope': <function getAssetIdForScope at 0x15a58c0>, 'getAssetVersions': <function getAssetVersions at 0x15a55f0>, 'resolveAllAssets': <function resolveAllAssets at 0x15a5410>, '__dict__': <attribute '__dict__' of 'BaseAssetPlugin' objects>, '__weakref__': <attribute '__weakref__' of 'BaseAssetPlugin' objects>, 'reset': <function reset at 0x15a5140>, 'postCreateAsset': <function postCreateAsset at 0x15a59b0>, 'resolvePath': <function resolvePath at 0x15a5488>, 'getUniqueScenegraphLocationFromAssetId': <function getUniqueScenegraphLocationFromAssetId at 0x15a5578>, 'runAssetPluginCommand': <function runAssetPluginCommand at 0x15a5320>, 'setAssetAttributes': <function setAssetAttributes at 0x15a5848>, 'getRelatedAssetId': <function getRelatedAssetId at 0x15a5668>, 'getAssetDisplayName': <function getAssetDisplayName at 0x15a5aa0>, 'buildAssetId': <function buildAssetId at 0x15a5758>, 'createTransaction': <function createTransaction at 0x15a5a28>, 'checkPermissions': <function checkPermissions at 0x15a52a8>, '__doc__': None, 'isAssetId': <function isAssetId at 0x15a51b8>, 'getAssetFields': <function getAssetFields at 0x15a56e0>})
__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 new file sequence plugin in to the Katana plugin registry. Takes the name of the plugin as the first argument and an instance of it as the second.

class AssetAPI.BaseFileSequencePlugin

Bases: object

Primary class to derive from when implementing file sequence plugin.

__dict__ = dict_proxy({'buildFileSequenceString': <function buildFileSequenceString at 0x15a5d70>, '__module__': 'AssetAPI.BaseFileSeqPlugin', '__dict__': <attribute '__dict__' of 'BaseFileSequencePlugin' objects>, 'isFileSequence': <function isFileSequence at 0x15a5cf8>, '__weakref__': <attribute '__weakref__' of 'BaseFileSequencePlugin' objects>, 'findSequence': <function findSequence at 0x15a5de8>, 'getFileSequence': <function getFileSequence at 0x15a5c80>, '__doc__': '\n Primary class to derive from when implementing file sequence plugin.\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.

__dict__ = dict_proxy({'getDirectory': <function getDirectory at 0x15a5f50>, '__module__': 'AssetAPI.BaseFileSeqPlugin', 'getNearestFrames': <function getNearestFrames at 0x15aa410>, 'getLastFrame': <function getLastFrame at 0x15aa398>, 'getSuffix': <function getSuffix at 0x15aa0c8>, 'getPadding': <function getPadding at 0x15aa140>, 'getResolvedPath': <function getResolvedPath at 0x15aa1b8>, 'hasFrame': <function hasFrame at 0x15aa2a8>, 'getPrefix': <function getPrefix at 0x15aa050>, '__weakref__': <attribute '__weakref__' of 'BaseFileSequence' objects>, 'getAsString': <function getAsString at 0x15a5ed8>, '__dict__': <attribute '__dict__' of 'BaseFileSequence' objects>, 'hasFrameSet': <function hasFrameSet at 0x15aa230>, 'getFrameList': <function getFrameList at 0x15aa488>, 'getFirstFrame': <function getFirstFrame at 0x15aa320>, '__doc__': '\n Class that constructs a file sequence object instance for a given file sequence string.\n ', '__init__': <function __init__ at 0x15a5e60>})
__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.