ynput / ayon-core

Apache License 2.0
26 stars 31 forks source link

Creators: fix undefined task name #480

Closed antirotor closed 4 months ago

antirotor commented 4 months ago

Changelog Description

When there was no taskEntity passed, task name was filled correctly but if not task name was None, passed down the line and causing crashes. This change is trying to find taskEntity and fill task name properly.

Testing notes:

Difficult to test as it depends on specific creator login at the end. But running something like this in Maya script editor should test it:

import ayon_api
from ayon_core.pipeline import registered_host
from ayon_core.pipeline.create import CreateContext

host = registered_host() 
context = CreateContext(host)
project_name = host.get_current_project_name()
folder_path = "/path/to/your/test/folder"
task_name = "layout"

folder_entity = ayon_api.get_folder_by_path(project_name, folder_path)

creator_identifier = f"io.openpype.creators.maya.layout"
task = ayon_api.get_task_by_name(project_name, folder_entity["id"], task_name)

context_set = context.create(
            creator_identifier,
            variant="Main",
            folder_entity=ayon_api.get_folder_by_path(project_name, folder_path),
            task_entity=ayon_api.get_task_by_name(project_name, folder_entity["id"], task_name),
            pre_create_data={"use_selection": False}
)