Skip to main content

Tasks

The Tasks API provides functionality for creating and managing tasks within Anchorpoint projects. Tasks help organize work items and metadata for project assets and workflows.

Usage

import apsync
import anchorpoint

ctx = anchorpoint.get_context()
api = anchorpoint.get_api()

# Access tasks through the API
tasks_api = api.tasks

# Create a task list for organizing tasks
task_list = tasks_api.create_task_list(ctx.folder, "Asset Tasks")

# Create a new task in the task list
task = tasks_api.create_task(task_list, "Review character model")

# Or create a task by finding/creating a task list by name
task2 = tasks_api.create_task(ctx.folder, "Asset Tasks", "Check topology")

print(f"Created task: {task.name}")
print(f"Task ID: {task.id}")
print(f"List ID: {task.list_id}")

Task Class

apsync.Task

The Task class represents an individual work item within a task list.

Properties

  • icon (class: Icon or None): Optional icon for the task. Can be set using the Tasks API methods.
  • id (str): Unique identifier for the task. Automatically generated when task is created.
  • list_id (str): ID of the task list this task belongs to. Links task to its containing list.
  • name (str): Title or name of the task. Brief description of what needs to be done.
  • project_id (str or None): ID of the project this task belongs to. Can be None for workspace-level tasks.
  • workspace_id (str): The ID of the workspace this task belongs to. Always present for all tasks.

TaskList Class

apsync.TaskList

The TaskList class provides a container for organizing related tasks.

Properties

  • id (str): Unique identifier for the task list. Automatically generated when task list is created.
  • name (str): Name of the task list. Brief title describing the task collection.
  • project_id (str or None): ID of the project this task list belongs to. Can be None for workspace-level task lists.
  • workspace_id (str): ID of the workspace this task list belongs to. Always present for all task lists.

Tasks API

The Tasks API is accessed through api.tasks and provides task management functionality.

Methods

  • copy_task(task) Creates a copy of an existing task.

    Arguments

    • task (class: Task): Task to copy

    Returns (class: Task): New task object that is a copy of the original

  • create_task(task_list, name) Creates a new task in a given task list.

    Arguments

    • task_list (class: TaskList): The task list to add the task to
    • name (str): Name of the task

    Returns (class: Task): Created task object

  • create_task(target, task_list_name, name) Creates a new task by finding or creating a task list by name.

    Arguments

    • target (str): The folder used to search for task lists
    • task_list_name (str): The name of the task list
    • name (str): Name of the task

    Returns (class: Task): Created task object

  • create_task_list(target, name) Creates a new task list at the specified location.

    Arguments

    • target (str): Path where the task list should be created
    • name (str): Name of the task list

    Returns (class: TaskList) - Created task list object

  • get_task(task_list, name) Retrieves a task by name from a task list.

    Arguments

    • task_list (class: TaskList): Task list to search
    • name (str): Name of the task to find

    Returns (class: Task or None) - Task object or None if not found

  • get_task_by_id(id) Retrieves a task by its unique identifier.

    Arguments

    • id (str): Unique identifier of the task

    Returns (class: Task) - Task object

  • get_task_list(target, name) Retrieves a task list by name from the specified location.

    Arguments

    • target (str): Path where to look for the task list
    • name (str): Name of the task list

    Returns (class: TaskList or None) - Task list object or None if not found

  • get_task_list_by_id(id) Retrieves a task list by its unique identifier.

    Arguments

    • id (str): Unique identifier of the task list

    Returns (class: TaskList) - Task list object

  • get_task_lists(target) Gets all task lists at the specified location.

    Arguments

    • target (str): Path where to look for task lists

    Returns (list of TaskList) - List of task lists found

  • get_tasks(task_list) Gets all tasks within a task list.

    Arguments

    • task_list (class: TaskList): Task list to get tasks from

    Returns (list of Task) - List of tasks in the task list

  • remove_task(task) Removes a task permanently.

    Arguments

    • task (class: Task): Task to remove
  • remove_task_list(task_list) Removes a task list and all its tasks permanently.

    Arguments

    • task_list (class: TaskList): Task list to remove
  • rename_task(task, name) Renames a task.

    Arguments

    • task (class: Task): Task to rename
    • name (str): New name for the task
  • rename_task_list(task_list, name) Renames a task list.

    Arguments

    • task_list (class: TaskList): Task list to rename
    • name (str): New name for the task list
  • set_task_icon(task, icon) Sets the icon for a task.

    Arguments

    • task (class: Task): Task to set icon for
    • icon (class: Icon or None): Icon to set, or None to remove icon
  • set_task_icons(tasks, icon) Sets the same icon for multiple tasks.

    Arguments

    • tasks (list of Task): List of tasks to set icon for
    • icon (class: Icon or None): Icon to set, or None to remove icons

Examples

Basic Task Creation

import apsync
import anchorpoint

ctx = anchorpoint.get_context()
api = anchorpoint.get_api()

# Create a task list first
task_list = api.tasks.create_task_list(ctx.folder, "Review Tasks")

# Create a new task in the task list
task = api.tasks.create_task(task_list, "Review concept art")

print(f"Created task: {task.name}")
print(f"Task ID: {task.id}")
print(f"Task list ID: {task.list_id}")
print(f"Workspace ID: {task.workspace_id}")

Managing Task Lists

import apsync
import anchorpoint

ctx = anchorpoint.get_context()
api = anchorpoint.get_api()

# Create a task list for character development
task_list = api.tasks.create_task_list(ctx.folder, "Character Development")

# Create multiple related tasks
task_names = ["Concept Design", "3D Modeling", "Texturing", "Rigging"]

created_tasks = []
for name in task_names:
# Use the overload that finds/creates task list by name
task = api.tasks.create_task(ctx.folder, "Character Development", name)
created_tasks.append(task)

print(f"Created {len(created_tasks)} tasks")

# Get all tasks in the task list
all_tasks = api.tasks.get_tasks(task_list)
print(f"Task list contains {len(all_tasks)} tasks")

Task Management Operations

import apsync
import anchorpoint

ctx = anchorpoint.get_context()
api = anchorpoint.get_api()

# Get an existing task list
task_list = api.tasks.get_task_list(ctx.folder, "Asset Tasks")

if task_list:
# Get all tasks in the list
tasks = api.tasks.get_tasks(task_list)

for task in tasks:
print(f"Task: {task.name}")
print(f" ID: {task.id}")
print(f" List ID: {task.list_id}")
print(f" Project ID: {task.project_id}")
print(f" Workspace ID: {task.workspace_id}")

# Check if task has an icon
if task.icon:
print(f" Icon: {task.icon.path}")

print()

# Find a specific task by name
review_task = api.tasks.get_task(task_list, "Review character model")
if review_task:
print(f"Found task: {review_task.name}")

Task Icon Management

import apsync
import anchorpoint

ctx = anchorpoint.get_context()
api = anchorpoint.get_api()

# Create an icon for high priority tasks
high_priority_icon = apsync.Icon("qrc:/icons/interface/warning.svg", "red")

# Get a task and set its icon
task_list = api.tasks.get_task_list(ctx.folder, "Project Tasks")
if task_list:
tasks = api.tasks.get_tasks(task_list)

# Set icon for individual task
if tasks:
api.tasks.set_task_icon(tasks[0], high_priority_icon)
print(f"Set icon for task: {tasks[0].name}")

# Set same icon for multiple tasks
urgent_tasks = [t for t in tasks if "urgent" in t.name.lower()]
if urgent_tasks:
api.tasks.set_task_icons(urgent_tasks, high_priority_icon)
print(f"Set icons for {len(urgent_tasks)} urgent tasks")