mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
OP-2518 - renamed to CollectColorCodedInstances
Updated logic for storing layer to instance.data
This commit is contained in:
parent
922da278e4
commit
697bc11036
7 changed files with 52 additions and 32 deletions
|
|
@ -186,9 +186,26 @@ class PhotoshopServerStub:
|
|||
Returns:
|
||||
<list of PSItem>
|
||||
"""
|
||||
parent_ids = set([lay.id for lay in layers])
|
||||
|
||||
return self._get_layers_in_layers(parent_ids)
|
||||
|
||||
def get_layers_in_layers_ids(self, layers_ids):
|
||||
"""Return all layers that belong to layers (might be groups).
|
||||
|
||||
Args:
|
||||
layers <list of PSItem>:
|
||||
|
||||
Returns:
|
||||
<list of PSItem>
|
||||
"""
|
||||
parent_ids = set(layers_ids)
|
||||
|
||||
return self._get_layers_in_layers(parent_ids)
|
||||
|
||||
def _get_layers_in_layers(self, parent_ids):
|
||||
all_layers = self.get_layers()
|
||||
ret = []
|
||||
parent_ids = set([lay.id for lay in layers])
|
||||
|
||||
for layer in all_layers:
|
||||
parents = set(layer.parents)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from openpype.lib.plugin_tools import parse_json, get_batch_asset_task_info
|
|||
from openpype.hosts.photoshop import api as photoshop
|
||||
|
||||
|
||||
class CollectRemoteInstances(pyblish.api.ContextPlugin):
|
||||
class CollectColorCodedInstances(pyblish.api.ContextPlugin):
|
||||
"""Creates instances for configured color code of a layer.
|
||||
|
||||
Used in remote publishing when artists marks publishable layers by color-
|
||||
|
|
@ -37,7 +37,7 @@ class CollectRemoteInstances(pyblish.api.ContextPlugin):
|
|||
flatten_subset_template = ""
|
||||
|
||||
def process(self, context):
|
||||
self.log.info("CollectRemoteInstances")
|
||||
self.log.info("CollectColorCodedInstances")
|
||||
self.log.debug("mapping:: {}".format(self.color_code_mapping))
|
||||
|
||||
existing_subset_names = self._get_existing_subset_names(context)
|
||||
|
|
@ -48,7 +48,6 @@ class CollectRemoteInstances(pyblish.api.ContextPlugin):
|
|||
|
||||
publishable_layers = []
|
||||
created_instances = []
|
||||
contains_background = False
|
||||
for layer in layers:
|
||||
self.log.debug("Layer:: {}".format(layer))
|
||||
if layer.parents:
|
||||
|
|
@ -82,12 +81,8 @@ class CollectRemoteInstances(pyblish.api.ContextPlugin):
|
|||
"Subset {} already created, skipping.".format(subset))
|
||||
continue
|
||||
|
||||
if layer.id == "1":
|
||||
contains_background = True
|
||||
|
||||
instance = self._create_instance(context, layer, resolved_family,
|
||||
asset_name, subset, task_name)
|
||||
|
||||
existing_subset_names.append(subset)
|
||||
publishable_layers.append(layer)
|
||||
created_instances.append(instance)
|
||||
|
|
@ -98,19 +93,17 @@ class CollectRemoteInstances(pyblish.api.ContextPlugin):
|
|||
self.log.warning("No template for flatten image")
|
||||
return
|
||||
|
||||
if contains_background:
|
||||
raise ValueError("It is not possible to create flatten image "
|
||||
"with background layer. Please remove it.")
|
||||
|
||||
fill_pairs.pop("layer")
|
||||
subset = self.flatten_subset_template.format(
|
||||
**prepare_template_data(fill_pairs))
|
||||
|
||||
stub.select_layers(publishable_layers)
|
||||
new_layer = stub.group_selected_layers(subset)
|
||||
instance = self._create_instance(context, new_layer,
|
||||
resolved_family,
|
||||
first_layer = publishable_layers[0] # dummy layer
|
||||
first_layer.name = subset
|
||||
family = created_instances[0].data["family"] # inherit family
|
||||
instance = self._create_instance(context, first_layer,
|
||||
family,
|
||||
asset_name, subset, task_name)
|
||||
instance.data["ids"] = [layer.id for layer in publishable_layers]
|
||||
created_instances.append(instance)
|
||||
|
||||
for instance in created_instances:
|
||||
|
|
@ -155,12 +148,12 @@ class CollectRemoteInstances(pyblish.api.ContextPlugin):
|
|||
def _create_instance(self, context, layer, family,
|
||||
asset, subset, task_name):
|
||||
instance = context.create_instance(layer.name)
|
||||
instance.append(layer)
|
||||
instance.data["family"] = family
|
||||
instance.data["publish"] = True
|
||||
instance.data["asset"] = asset
|
||||
instance.data["task"] = task_name
|
||||
instance.data["subset"] = subset
|
||||
instance.data["layer"] = layer
|
||||
|
||||
return instance
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ class CollectInstances(pyblish.api.ContextPlugin):
|
|||
# continue
|
||||
|
||||
instance = context.create_instance(layer_data["subset"])
|
||||
instance.append(layer)
|
||||
instance.data["layer"] = layer
|
||||
instance.data.update(layer_data)
|
||||
instance.data["families"] = self.families_mapping[
|
||||
layer_data["family"]
|
||||
|
|
|
|||
|
|
@ -27,8 +27,13 @@ class ExtractImage(openpype.api.Extractor):
|
|||
self.log.info("Extracting %s" % str(list(instance)))
|
||||
with photoshop.maintained_visibility():
|
||||
# Hide all other layers.
|
||||
layer = instance.data.get("layer")
|
||||
ids = set([layer.id])
|
||||
add_ids = instance.data.pop("ids", None)
|
||||
if add_ids:
|
||||
ids.update(set(add_ids))
|
||||
extract_ids = set([ll.id for ll in stub.
|
||||
get_layers_in_layers([instance[0]])])
|
||||
get_layers_in_layers_ids(ids)])
|
||||
|
||||
for layer in stub.get_layers():
|
||||
# limit unnecessary calls to client
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class ExtractReview(openpype.api.Extractor):
|
|||
for image_instance in instance.context:
|
||||
if image_instance.data["family"] != "image":
|
||||
continue
|
||||
layers.append(image_instance[0])
|
||||
layers.append(image_instance.data.get("layer"))
|
||||
|
||||
# Perform extraction
|
||||
output_image = "{}.jpg".format(
|
||||
|
|
|
|||
|
|
@ -7,15 +7,10 @@
|
|||
}
|
||||
},
|
||||
"publish": {
|
||||
"CollectRemoteInstances": {
|
||||
"color_code_mapping": [
|
||||
{
|
||||
"color_code": [],
|
||||
"layer_name_regex": [],
|
||||
"family": "image",
|
||||
"subset_template_name": ""
|
||||
}
|
||||
]
|
||||
"CollectColorCodedInstances": {
|
||||
"create_flatten_image": false,
|
||||
"flatten_subset_template": "",
|
||||
"color_code_mapping": []
|
||||
},
|
||||
"ValidateContainers": {
|
||||
"enabled": true,
|
||||
|
|
|
|||
|
|
@ -37,12 +37,22 @@
|
|||
"type": "dict",
|
||||
"collapsible": true,
|
||||
"is_group": true,
|
||||
"key": "CollectRemoteInstances",
|
||||
"label": "Collect Instances for Webpublish",
|
||||
"key": "CollectColorCodedInstances",
|
||||
"label": "Collect Color Coded Instances",
|
||||
"children": [
|
||||
{
|
||||
"type": "label",
|
||||
"label": "Set color for publishable layers, set publishable families."
|
||||
"label": "Set color for publishable layers, set its resulting family and template for subset name. Can create flatten image from published instances"
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
"key": "create_flatten_image",
|
||||
"label": "Create flatten image"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "flatten_subset_template",
|
||||
"label": "Subset template for flatten image"
|
||||
},
|
||||
{
|
||||
"type": "list",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue