Hello, I’m trying to write a script to batch load assets into a maya scene based on some data from the kitsu api.
I hit a bit of a roadblock when it comes to loading a product inside maya.
This is a snippet of the code:
import ayon_api
from ayon_core.pipeline import (
get_current_context,
discover_loader_plugins,
load_container
)
context = get_current_context()
project_name = context["project_name"]
# get loader
loader_name = "ReferenceLoader"
all_loaders = discover_loader_plugins()
Loader = next((i for i in all_loaders if i.__name__ == loader_name), None)
if Loader is None:
raise RuntimeError
# load product
folder_ids = ["f3ff351ee16811ef8faaba486748ad4c"]
products = ayon_api.get_products(project_name, folder_ids=folder_ids)
for product in products:
load_container(Loader, product) # ??
# This requires a representation instead of a product
# Is there a way to load a product? Or get a representation from a product?
What function would i have to call to load a product? Or is there a way through the api to get a representation from a product?
You are likely looking for ayon_api.get_representations or ayon_api.get_representation_by_name or alike?
However, this does beg the question - why do you need to do this batch loading?
Are you aware we support Workfile templates for example, where upon starting a task the template can be “build” based on your own predefined template, which also allows e.g. batch loading data into the scene (even into groups you have pre-specified, etc.)
I want to use this for building for example an animation scene.
Where the script would load all of the characters associated with that shot.
This association is defined in kitsu, so i get the data from there and load the associated ayon products.
Can this be achieved with workfile templates? As far as i understand, when setting up a placeholder you can’t specify this dynamic connections.
However, the intend would be the same. It’d load the “linked assets” in how they are linked in AYON. If that data comes from Kitsu, you’d need to however ensure some syncing occurs from Kitsu to AYON of course, when that’s the case then it’d work natively in AYON using the workfile templates.
For information, The feature you’ve described is expected to be achieved by the Node Graph addon.
It should be achieved by the Node Graph Addon which is still in development as far as I know.
Not necessarily - the links API is fully functional and can be used currently. However, a good frontend to create these links visually inside the AYON web frontend itself is still work-in-progress.
Since in this case the data is available in Kitsu - it’d just mean you’d need to get that data into AYON links, for which the API is fully functional to create those links, etc.