Breakdown API
BreakdownManager
- class tk_multi_breakdown2.api.BreakdownManager(bundle)[source]
Bases:
object
This class is used for managing and executing file updates.
Initialize the manager.
- get_scene_objects(execute_in_main_thread=True)[source]
Get the current scene objects by executing the scan_scene hook method.
A list of dictionaries representing the scene references will be returned. The return dict value has the following key-values:
- node (str)
The name of the node which holds the reference.
- type (str)
The node type.
- path (str)
The reference file path.
- extra_data (dict)
Extra data for the reference (optional).
- Parameters:
execute_in_main_thread (bool) – True will ensure the hook method is executed in the main thread, else False will execute in the current thread. Default is True, since the scan_scene function will need to execute DCC functionality that likely needs to execute in the main thread (e.g. GUI events).
- Returns:
A list of scene references.
- Return type:
List[dict]
- scan_scene(extra_fields=None, execute_in_main_thread=True)[source]
Scan the current scene to return a list of scene references.
A list of FileItem objects representing the scene references will be returned.
- Parameters:
execute_in_main_thread (bool) – True will ensure the hook method is executed in the main thread, else False will execute in the current thread. Default is True, since the scan_scene function will need to execute DCC functionality that likely needs to execute in the main thread (e.g. GUI events).
- Returns:
A list of scene references.
- Return type:
List[FileItem]
- get_published_files_from_file_paths(file_paths, extra_fields=None, bg_task_manager=None)[source]
Query the Flow Production Tracking API to get the published files for the given file paths.
- Parameters:
file_paths (List[str]) – A list of file paths to get the published files from.
extra_fields (List[str]) – A list of Flow Production Tracking fields to append to the Flow Production Tracking query when retreiving the published files.
bg_task_manager – (optional) A background task manager to execute the request async. If not provided, the request will be executed synchronously.
- Type:
BackgroundTaskManager
- Returns:
The task id for the request is returned if executed async, else the published files data is returned if executed synchronosly.
- Return type:
- get_file_items(scene_objects, published_files)[source]
Get the file item objects for the given scene objects.
Scene objects that do not have a corresponding Flow Production Tracking Published File will be omitted from the result (a FileItem will not be created for it).
The scene_objects dict param expects the key-values:
- node (str)
The name of the node which holds the reference.
- type (str)
The node type.
- path (str)
The reference file path.
- extra_data (dict)
Extra data for the reference (optional).
- Parameters:
scene_objects (dict) – Objects from the DCC. This value can be the result returned by the scan_scene method.
published_files – The list of published files corresponding to the scene_objects. Any scene objects that do not have a matching published will be omitted from the result (there will not be a FileItem object created for it). This can be the result returned by the sgtk.util.find_publish method.
- Returns:
A list of FileItem objects representing the scene objects.
- Return type:
List[FileItem]
- get_published_file_fields()[source]
Get the fields to pass to the query to retrieve the published files when scanning the scene.
- Returns:
The published file fields.
- Return type:
list<str>
- get_published_file_filters()[source]
Get additional filters to pass to the query to retrieve the published files when scanning the scene.
- Returns:
The published file filters.
- Return type:
List[List[dict]]
- get_history_published_file_filters()[source]
Get additional filters to pass to the query to retrieve the history published files for a given file item.
- get_latest_published_file(item, data_retriever=None, extra_fields=None)[source]
Get the latest available published file according to the current item context.
- Parameters:
item (FileItem) – :class`FileItem` object we want to get the latest published file
data_retreiver – If provided, the api request will be async. The default value will execute the api request synchronously.
- Returns:
The latest published file as a Flow Production Tracking entity dictionary if the request was synchronous, else the request background task id if the request was async.
- get_published_files_for_items(items, data_retriever=None, extra_fields=None)[source]
Get all published files (history) for the given items.
- Parameters:
items (List[FileItem]) – the list of :class`FileItem` we want to get published files for.
data_retreiver – If provided, the api request will be async. The default value will execute the api request synchronously.
- Returns:
If the request is async, then the request task id is returned, else the published file data result from the api request.
- Return type:
- get_published_file_history(item, extra_fields=None, data_retriever=None)[source]
Get the published history for the selected item. It will gather all the published files with the same context than the current item (project, name, task, …)
- Parameters:
item (FileItem) – :class`FileItem` object we want to get the published file history
extra_fields (List[str]) – A list of Flow Production Tracking fields to append to the Flow Production Tracking query fields.
data_retreiver – If provided, the api request will be async. The default value will execute the api request synchronously.
- Returns:
If the request is async, then the request task id is returned, else the published file history.
- Return type:
- update_items_to_latest_version(items)[source]
Update the list of items to their respective latest version.
FileItem
- class tk_multi_breakdown2.api.FileItem(node_name, node_type, path, sg_data=None, extra_data=None, locked=False, loaded=True)[source]
Bases:
object
Encapsulate details about a single version of a file. Each instance represents a single “version” but will contain details about the latest available version of the file.
Class constructor.
- Parameters:
node_name – Name of the file node
node_type – Type of the file node
path – Path on disk of this file
sg_data – Dictionary of Flow Production Tracking data representing this file in the database
extra_data – Dictionary containing additional information about this file
locked – True if the file item is locked, else False.
loaded – True if the file item is loaded, else False.
- property highest_version_number
Get highest version number available in the Flow Production Tracking database for this file.
- property node_name
Get the name of the file node.
- property node_type
Get the type of the file node.
- property path
Get the path on disk for this file item.
- property locked
Get whether or not this file item is locked.
- property loaded
Get whether or not this file item is loaded.
- property latest_published_file
Get the latest published file for this file item.
- property extra_data
Get or set the extra data associated with this item.
- property sg_data
Get or set the Flow Production Tracking data associated with this item.
- property thumbnail_path
Get or set the thumbnail path for this item.