-
Notifications
You must be signed in to change notification settings - Fork 129
Photoshop: implemented {layer} placeholder in subset template #3591
Photoshop: implemented {layer} placeholder in subset template #3591
Conversation
…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!
@@ -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 |
There was a problem hiding this comment.
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": ""} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
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.
Testing notes:
{Variant}{layer}
would be actually preferred)