Skip to content

Commit

Permalink
Fix exception even for different use case
Browse files Browse the repository at this point in the history
  • Loading branch information
kalisp committed May 7, 2024
1 parent a3c4817 commit f1afd16
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions client/ayon_core/hosts/photoshop/plugins/create/create_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ def create(self, product_name_from_ui, data, pre_create_data):
create_empty_group = False

stub = api.stub() # only after PS is up
try:
top_level_selected_items = stub.get_selected_layers()
except ValueError:
raise CreatorError("Cannot group locked Background layer!")
if pre_create_data.get("use_selection"):
try:
top_level_selected_items = stub.get_selected_layers()
except ValueError:
raise CreatorError("Cannot group locked Background layer!")

only_single_item_selected = len(top_level_selected_items) == 1
if (
only_single_item_selected or
Expand All @@ -53,8 +54,11 @@ def create(self, product_name_from_ui, data, pre_create_data):
group = stub.group_selected_layers(product_name_from_ui)
groups_to_create.append(group)
else:
stub.select_layers(stub.get_layers())
group = stub.group_selected_layers(product_name_from_ui)
try:
stub.select_layers(stub.get_layers())
group = stub.group_selected_layers(product_name_from_ui)
except ValueError:
raise CreatorError("Cannot group locked Background layer!")

groups_to_create.append(group)

Expand Down

0 comments on commit f1afd16

Please sign in to comment.