Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Photoshop: implemented {layer} placeholder in subset template #3591

Conversation

kalisp
Copy link
Member

@kalisp kalisp commented Jul 28, 2022

Brief description

Previously when layer name is added to subset name (in case of multiple instances created in one go), group (layer) name
was concatenated (capitalized). Customer wants better control.

Description

{layer} placeholder (and all its variants {Layer}, {LAYER}) could be added to project_settings/global/tools/creator/subset_name_profiles to control how layer name should look like.

Additional info

{layer} means keep layer name as it was, not lowercased!
Be careful with delimiters as '_{layer}' as for single subset it would leave trailing underline.

layer_subset

Testing notes:

  1. Configure Setting accordingly to attached screenshot ({Variant}{layer} would be actually preferred)
  2. create instances from multiple selected layers (in legacy and New Publisher)

…legacy creator

{layer} placeholder could be used in project_settings/global/tools/creator/subset_name_profiles to drive lower/upper cases when layer is used in subset name (eg. when multiple subsets are created at once).
Warning {layer} means keep layer name as it is, not lowercasing!
@kalisp kalisp added type: enhancement Enhancements to existing functionality sponsored Client endorsed or requested labels Jul 28, 2022
@kalisp kalisp requested a review from 64qam July 28, 2022 11:00
@kalisp kalisp self-assigned this Jul 28, 2022
@ynbot
Copy link
Contributor

ynbot commented Jul 28, 2022

@@ -143,3 +152,9 @@ def _handle_legacy(self, instance_data):
def _clean_highlights(self, stub, item):
return item.replace(stub.PUBLISH_ICON, '').replace(stub.LOADED_ICON,
'')
@classmethod
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expected 1 blank line, found 0

cls, variant, task_name, asset_id, project_name, host_name
):
"""Called by UI, empty value for layer must be provided."""
return {"layer": ""}
Copy link
Member

@iLLiCiTiT iLLiCiTiT Jul 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe simpler variant would be to return formattings placeholder and fill it in create?

def get_dynamic_data(cls, *args, **kwargs):
    return {"layer": "{layer}"}

And in create:

layer_name = ""
if len(groups) > 1:
    layer_name = group.name
layer_fill = prepare_template_data({"layer": layer_name})
subset_name = subset_name.format(**layer_fill)

You don't need to duplicate code with get_subset_template and get_subset_name_for_multiple and artist will see {layer} in subset name before create.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't work if layer name is not used in subset name (which might not be all the time).

Copy link
Member

@iLLiCiTiT iLLiCiTiT Jul 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would just not fill it. In that case the subset name would stay unchanged which is not an issue.

layer_name = "something"
# Both would work
subset_name = "renderMain" # renderMain{Layer}"
layer_fill = prepare_template_data({"layer": layer_name})
# This would just won't do anything
subset_name = subset_name.format(**layer_fill)
print(subset_name)

If creator was configured to not use selection and not create multiple, it failed before. (It should create one wrapping group, eg. instance, around all. Locked background layer cannot be present!)
stub.select_layers(stub.get_layers())
try:
group = stub.group_selected_layers(subset_name_from_ui)
except:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use bare except:, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer except Exception:. If you're sure what you're doing, be explicit and write except BaseException:.
do not use bare 'except'

Easier solution found without reinventing logic.
…P-3283_Allow-subset-template-name-for-manual-Create-in-Photoshop
Removal of invalid characters must be done in Create phase to persist.
@kalisp kalisp merged commit b2f35a3 into develop Aug 1, 2022
@kalisp kalisp deleted the feature/OP-3283_Allow-subset-template-name-for-manual-Create-in-Photoshop branch August 1, 2022 08:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
sponsored Client endorsed or requested type: enhancement Enhancements to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants