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

Commit

Permalink
moved Creator to plugin.py
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT committed Jan 10, 2022
1 parent c2b6cf8 commit b6a5123
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
34 changes: 0 additions & 34 deletions openpype/hosts/photoshop/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,40 +193,6 @@ def _get_stub():
return stub


class Creator(avalon.api.Creator):
"""Creator plugin to create instances in Photoshop
A LayerSet is created to support any number of layers in an instance. If
the selection is used, these layers will be added to the LayerSet.
"""

def process(self):
# Photoshop can have multiple LayerSets with the same name, which does
# not work with Avalon.
msg = "Instance with name \"{}\" already exists.".format(self.name)
stub = lib.stub() # only after Photoshop is up
for layer in stub.get_layers():
if self.name.lower() == layer.Name.lower():
msg = QtWidgets.QMessageBox()
msg.setIcon(QtWidgets.QMessageBox.Warning)
msg.setText(msg)
msg.exec_()
return False

# Store selection because adding a group will change selection.
with lib.maintained_selection():

# Add selection to group.
if (self.options or {}).get("useSelection"):
group = stub.group_selected_layers(self.name)
else:
group = stub.create_group(self.name)

stub.imprint(group, self.data)

return group


def containerise(
name, namespace, layer, context, loader=None, suffix="_CON"
):
Expand Down
34 changes: 34 additions & 0 deletions openpype/hosts/photoshop/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,37 @@ class PhotoshopLoader(avalon.api.Loader):
@staticmethod
def get_stub():
return stub()


class Creator(avalon.api.Creator):
"""Creator plugin to create instances in Photoshop
A LayerSet is created to support any number of layers in an instance. If
the selection is used, these layers will be added to the LayerSet.
"""

def process(self):
# Photoshop can have multiple LayerSets with the same name, which does
# not work with Avalon.
msg = "Instance with name \"{}\" already exists.".format(self.name)
stub = lib.stub() # only after Photoshop is up
for layer in stub.get_layers():
if self.name.lower() == layer.Name.lower():
msg = QtWidgets.QMessageBox()
msg.setIcon(QtWidgets.QMessageBox.Warning)
msg.setText(msg)
msg.exec_()
return False

# Store selection because adding a group will change selection.
with lib.maintained_selection():

# Add selection to group.
if (self.options or {}).get("useSelection"):
group = stub.group_selected_layers(self.name)
else:
group = stub.create_group(self.name)

stub.imprint(group, self.data)

return group

0 comments on commit b6a5123

Please sign in to comment.