mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
use group name as default value for RenderLayer
This commit is contained in:
parent
7a0ec6bb93
commit
3b348f2af3
1 changed files with 39 additions and 1 deletions
|
|
@ -1,4 +1,8 @@
|
|||
from avalon.tvpaint import pipeline, lib
|
||||
from avalon.tvpaint import (
|
||||
pipeline,
|
||||
lib,
|
||||
CommunicationWrapper
|
||||
)
|
||||
from openpype.hosts.tvpaint.api import plugin
|
||||
|
||||
|
||||
|
|
@ -18,6 +22,40 @@ class CreateRenderlayer(plugin.Creator):
|
|||
" {clip_id} {group_id} {r} {g} {b} \"{name}\""
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_default_variant(cls):
|
||||
"""Default value for variant in Creator tool.
|
||||
|
||||
Method checks if TVPaint implementation is running and tries to find
|
||||
selected layers from TVPaint. If only one is selected it's name is
|
||||
returned.
|
||||
|
||||
Returns:
|
||||
str: Default variant name for Creator tool.
|
||||
"""
|
||||
# Validate that communication is initialized
|
||||
if CommunicationWrapper.communicator:
|
||||
# Get currently selected layers
|
||||
layers_data = lib.layers_data()
|
||||
|
||||
group_ids = set()
|
||||
for layer in layers_data:
|
||||
if layer["selected"]:
|
||||
group_ids.add(layer["group_id"])
|
||||
|
||||
# Return layer name if only one is selected
|
||||
if len(group_ids) == 1:
|
||||
group_id = list(group_ids)[0]
|
||||
groups_data = lib.groups_data()
|
||||
for group in groups_data:
|
||||
if group["group_id"] == group_id:
|
||||
return group["name"]
|
||||
|
||||
# Use defaults
|
||||
if cls.defaults:
|
||||
return cls.defaults[0]
|
||||
return None
|
||||
|
||||
def process(self):
|
||||
self.log.debug("Query data from workfile.")
|
||||
instances = pipeline.list_instances()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue