diff --git a/sdppp_python/comfy/nodes.py b/sdppp_python/comfy/nodes.py index 015ba40..c6fa98c 100644 --- a/sdppp_python/comfy/nodes.py +++ b/sdppp_python/comfy/nodes.py @@ -509,9 +509,10 @@ def define_comfyui_nodes(sdpppServer): return (res_text,) - class RunPhotoshopActionNode: - RETURN_TYPES = ("DOCUMENT",) - RETURN_NAMES = ("document",) + class SelectLayerAndRunPSActionNode: + RETURN_TYPES = ("LAYER",) + RETURN_NAMES = ("layer_or_group",) + INPUT_IS_LIST = False FUNCTION = "action" CATEGORY = "SD-PPP" OUTPUT_NODE = True @@ -524,7 +525,7 @@ def define_comfyui_nodes(sdpppServer): def INPUT_TYPES(cls): return { "required": { - "document": ("DOCUMENT", {"default": None, "sdppp_type": "DOCUMENT"}), + "layer_or_group": ("LAYER", {"default": None, "sdppp_type": "LAYER"}), "action_set": ("STRING", {"default": "", "sdppp_type": "STRING"}), "action": ("STRING", {"default": "", "sdppp_type": "STRING"}), }, @@ -533,17 +534,19 @@ def define_comfyui_nodes(sdpppServer): }) } - def action(self, document, action_set, action, **kwargs): + def action(self, layer_or_group, action_set, action, **kwargs): sdpppServer.has_ps_instance(throw_error=True) - call_async_func_in_server_thread(ProtocolPhotoshop.run_photoshop_action( - instance_id=document['instance_id'], - document_identify=document['identify'], + start_time = time.time() + result = call_async_func_in_server_thread(ProtocolPhotoshop.run_photoshop_action( + instance_id=layer_or_group['document']['instance_id'], + document_identify=layer_or_group['document']['identify'], + layer_identify=layer_or_group['layer_identify'], action_set=action_set, action=action - ), True) - - return (document, ) + )) + print(result) + return (layer_or_group, ) @@ -573,6 +576,6 @@ def define_comfyui_nodes(sdpppServer): # 'SDPPP Send Text To Layer': SendTextToLayerNode, 'SDPPP Get Selection': GetSelectionNode, 'SDPPP Parse Layer Info': ParseLayerInfoNode, - 'SDPPP Run Photoshop Action': RunPhotoshopActionNode, + 'SDPPP Run PS Action On Layer': SelectLayerAndRunPSActionNode, # 'SDPPP Settings': SDPPPSettingsNode, } diff --git a/sdppp_python/comfy/nodes_legacy.py b/sdppp_python/comfy/nodes_legacy.py index e5c0efa..a0094a7 100644 --- a/sdppp_python/comfy/nodes_legacy.py +++ b/sdppp_python/comfy/nodes_legacy.py @@ -153,9 +153,9 @@ def define_comfyui_nodes_legacy(sdppp): class SendImageToPhotoshopLayerNode: - RETURN_TYPES = ("IMAGE",) - RETURN_NAMES = ("images",) - OUTPUT_IS_LIST = (True,) + RETURN_TYPES = ("LAYER",) + RETURN_NAMES = ("layer_or_group",) + OUTPUT_IS_LIST = (True, True) OUTPUT_NODE = True INPUT_IS_LIST = True FUNCTION = "send_image" @@ -237,7 +237,8 @@ def define_comfyui_nodes_legacy(sdppp): boundaries=[p['boundary'] for p in params], new_layer_name=sdppp_arg_item['lastOpenedWorkflow'] ), True) - return (images,) + ret_layer_or_group = None if not linked_style else layer_or_group + return (ret_layer_or_group,) class CLIPTextEncodePSRegional: @classmethod diff --git a/sdppp_python/protocols/photoshop.py b/sdppp_python/protocols/photoshop.py index ff4f112..51058a0 100644 --- a/sdppp_python/protocols/photoshop.py +++ b/sdppp_python/protocols/photoshop.py @@ -133,11 +133,14 @@ class ProtocolPhotoshop: return result @classmethod - async def run_photoshop_action(cls, instance_id, document_identify, action_set, action): + async def run_photoshop_action(cls, instance_id, document_identify, layer_identify, action_set, action): ppp_instance = cls.sdpppServer.ppp_instances[instance_id] + start = time.time() result = await protocol_call(ppp_instance, 'B_photoshop', data={ - 'action': 'runPhotoshopAction', + 'action': 'runPhotoshopActionOnLayer', 'params': { + 'document_identify': document_identify, + 'layer_identify': layer_identify, 'action_set': action_set, 'action': action } diff --git a/typescripts/modules/photoshop-internal b/typescripts/modules/photoshop-internal index d465259..871db48 160000 --- a/typescripts/modules/photoshop-internal +++ b/typescripts/modules/photoshop-internal @@ -1 +1 @@ -Subproject commit d465259886c5e585112a6f7c9d13b825ab2f097b +Subproject commit 871db48804abea016d9cc9058abcb061fc1fb7f1 diff --git a/typescripts/src/common/zh-cn.mts b/typescripts/src/common/zh-cn.mts index 50d1492..7478300 100644 --- a/typescripts/src/common/zh-cn.mts +++ b/typescripts/src/common/zh-cn.mts @@ -188,7 +188,8 @@ export default { 'sdppp extract PSD': 'sdppp 导入 PSD', 'sdppp get PSD': 'sdppp 获取 PSD', 'set text to layer': '设置图层的文本', - 'sdppp Run Photoshop Action': 'sdppp 运行 Photoshop Action', + 'run Photoshop Action': 'sdppp 运行 Photoshop Action', + 'select layer': 'sdppp 选中图层', // photoshop dialog/widget '{0} wants to extract a PSD file to Photoshop, are you sure?': '{0} 想要释放一个.psd文件到Photoshop,确定吗?', diff --git a/typescripts/src/socket/PhotoshopCalleeInterface.mts b/typescripts/src/socket/PhotoshopCalleeInterface.mts index 6a2d341..ccd7586 100644 --- a/typescripts/src/socket/PhotoshopCalleeInterface.mts +++ b/typescripts/src/socket/PhotoshopCalleeInterface.mts @@ -145,10 +145,12 @@ export interface LayerReducerActions { } // =========== runPhotoshopAction Interfaces =========== -export interface RunPhotoshopActionActions { +export interface RunPhotoshopActionOnLayerActions { params: { action_set: string, - action: string + action: string, + layer_identify: string, + document_identify: string }, result: { success: boolean @@ -178,7 +180,7 @@ export interface PhotoshopCalleeActions { getDocumentInfo: getDocumentInfoActions; getLinkedLayers: LayerReducerActions; getLayersInGroup: LayerReducerActions; - runPhotoshopAction: RunPhotoshopActionActions; + runPhotoshopActionOnLayer: RunPhotoshopActionOnLayerActions; getSpecialIdentifierValue: getSpecialIdentifierValueActions; }