-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#327: Creer un validator de blendMode sur les layers dans photoshop #43
Changes from all commits
d37e561
9496214
8cf716f
a09dec8
8aa64c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<root> | ||
<error id="main"> | ||
<title>BlendMode Error</title> | ||
<description> | ||
## Invalid blendMode on layer or group | ||
|
||
Layer must be in Normal blend and Groups in PassThrought. | ||
|
||
### How to repair? | ||
|
||
You can fix this with "repair" button on the right and press Refresh publishing button at the bottom right. | ||
</description> | ||
</error> | ||
</root> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import pyblish.api | ||
from openpype.pipeline.publish import ( | ||
ValidateContentsOrder, | ||
PublishXmlValidationError, | ||
OptionalPyblishPluginMixin | ||
) | ||
from openpype.hosts.photoshop import api as photoshop | ||
|
||
|
||
class ValidateBlendModeRepair(pyblish.api.Action): | ||
"""Repair the instance asset.""" | ||
|
||
label = "Repair" | ||
icon = "wrench" | ||
on = "failed" | ||
|
||
def process(self, context, plugin): | ||
|
||
stub = photoshop.stub() | ||
failed = context.data['transientData'][ValidateBlendMode.__name__] | ||
|
||
for layer, info in failed.items(): | ||
stub.set_blendmode(layer_name=layer, blendMode_name=info["defaultBlendMode"]) | ||
|
||
|
||
class ValidateBlendMode( | ||
OptionalPyblishPluginMixin, | ||
pyblish.api.ContextPlugin | ||
): | ||
"""Validate if the blendMode is set properly on Layers, NORMAL, and Groups, PASSTHROUGH | ||
""" | ||
|
||
label = "Validate BlendMode" | ||
hosts = ["photoshop"] | ||
order = ValidateContentsOrder | ||
families = ["image"] | ||
actions = [ValidateBlendModeRepair] | ||
optional = True | ||
active = False | ||
|
||
def process(self, context): | ||
|
||
if not self.is_active(context.data): | ||
return | ||
|
||
PASSTHROUGH = "passThrough" | ||
NORMAL = "normal" | ||
returnDict = {} | ||
msg = "" | ||
|
||
stub = photoshop.stub() | ||
layers = stub.get_layers() | ||
|
||
for layer in layers: | ||
layerDict = {} | ||
if (layer.group and layer.blendMode != PASSTHROUGH) or (not layer.group and layer.blendMode != NORMAL): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Et ici faire There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. il y a une logique There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comme vu dans la pr sur OpenPype, il n'y a pas de lien entre les classes et fonction dans le jsx et celles du py, les ID des blendModes ne correspondent pas entre l'api jsx et l'api python de Photoshop. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
layerDict["actualBlendMode"] = layer.blendMode | ||
layerDict["defaultBlendMode"] = PASSTHROUGH if layer.group else NORMAL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Passer ici un id une non une string |
||
returnDict[layer.name] = layerDict | ||
|
||
typeStr = "Group" if layer.group else "Layer" | ||
msg = "{}\n\n The {} {} is set to {}.".format(msg, typeStr, layer.name, layer.blendMode) | ||
|
||
else: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. le |
||
continue | ||
|
||
if returnDict: | ||
if not context.data.get('transientData'): | ||
context.data['transientData'] = dict() | ||
|
||
context.data['transientData'][self.__class__.__name__] = returnDict | ||
|
||
raise PublishXmlValidationError(self, msg) |
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.
Selon moi ici il faut retirer
PASSTHROUGH
etNORMAL
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.
En considérant qu'on garde le transfert d'info par str, on peut conserver ces var ou pas du coup ?
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.
Yes