Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hooks/tk-3dsmaxplus_actions.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this file? I'm surprised we missed it!

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MaxActions(HookBaseClass):
##############################################################################################################
# public interface - to be overridden by deriving classes

def generate_actions(self, sg_publish_data, actions, ui_area):
def generate_actions(self, sg_publish_data, actions, ui_area, **kwargs):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I'm injecting a new argument to the hook for flowam integration to work.

This is not needed on all DCCs (i.e. 3ds, photoshop) but it crashes due to the unexpected argument. So this is just adding the placeholder.

You can see the difference on this file and compare it to tk-maya_actions.py to have a better picture.

"""
Returns a list of action instances for a particular publish.
This method is called each time a user clicks a publish somewhere in the UI.
Expand Down Expand Up @@ -101,7 +101,7 @@ def generate_actions(self, sg_publish_data, actions, ui_area):

return action_instances

def execute_multiple_actions(self, actions):
def execute_multiple_actions(self, actions, **kwargs):
"""
Executes the specified action on a list of items.

Expand Down Expand Up @@ -132,7 +132,7 @@ def execute_multiple_actions(self, actions):
params = single_action["params"]
self.execute_action(name, params, sg_publish_data)

def execute_action(self, name, params, sg_publish_data):
def execute_action(self, name, params, sg_publish_data, **kwargs):
"""
Execute a given action. The data sent to this be method will
represent one of the actions enumerated by the generate_actions method.
Expand Down
112 changes: 61 additions & 51 deletions hooks/tk-desktop_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def generate_actions(
sg_publish_data: dict,
actions: list,
ui_area: str,
am_base_obj: Any = None,
**kwargs,
) -> list:
"""
Return a list of action instances for a particular publish.
Expand Down Expand Up @@ -77,67 +77,76 @@ def generate_actions(

action_instances = []

if "download" in actions and sg_publish_data.get("type") == "PublishedFile":
version_number = sg_publish_data.get("version_number")
enable_flowam = app.get_setting("enable_flowam", False)
if enable_flowam:
am_base_obj = kwargs.get("am_base_obj")
if not am_base_obj:
raise Exception(
"FlowAM is enabled but no Asset Management base object was passed to the action hook. "
"FlowAM specific actions will not be generated."
)

if (
version_number is not None
and version_number != am_base_obj.DRAFT_VERSION_IDENTIFIER
):
if "download" in actions and sg_publish_data.get("type") == "PublishedFile":
version_number = sg_publish_data.get("version_number")

if (
version_number is not None
and version_number != am_base_obj.DRAFT_VERSION_IDENTIFIER
):
action_instances.append(
{
"name": "download",
"params": "Download 'params'",
"caption": "Download",
"description": "Downloads the published file to a user specified location.",
}
)

if "publish" in actions:
# Show publish action only for published files (not drafts)
# Drafts (version == -1) are not supported in generic workflow
version_number = sg_publish_data.get("version_number")

if version_number is not None and version_number >= 0:
action_instances.append(
{
"name": "publish",
"params": "Publish 'params'",
"caption": "Publish",
"description": "Publish a new revision of this generic asset.",
}
)

if "create_generic_asset" in actions:
action_instances.append(
{
"name": "download",
"params": "Download 'params'",
"caption": "Download",
"description": "Downloads the published file to a user specified location.",
"name": "create_generic_asset",
"params": "Create Generic Asset 'params'",
"caption": "Create Generic Asset",
"description": "Executes Create Generic Asset.",
}
)

if "publish" in actions:
# Show publish action only for published files (not drafts)
# Drafts (version == -1) are not supported in generic workflow
version_number = sg_publish_data.get("version_number")

if version_number is not None and version_number >= 0:
if (
"reference_copy_link" in actions
and sg_publish_data.get(
"version_number", am_base_obj.DRAFT_VERSION_IDENTIFIER
)
> am_base_obj.DRAFT_VERSION_IDENTIFIER
):
action_instances.append(
{
"name": "publish",
"params": "Publish 'params'",
"caption": "Publish",
"description": "Publish a new revision of this generic asset.",
"name": "reference_copy_link",
"params": None,
"caption": "Copy Reference Link",
"description": "This will copy the reference as a string to the clipboard",
"multi_select": False,
}
)

if "create_generic_asset" in actions:
action_instances.append(
{
"name": "create_generic_asset",
"params": "Create Generic Asset 'params'",
"caption": "Create Generic Asset",
"description": "Executes Create Generic Asset.",
}
)

if (
"reference_copy_link" in actions
and sg_publish_data.get(
"version_number", am_base_obj.DRAFT_VERSION_IDENTIFIER
)
> am_base_obj.DRAFT_VERSION_IDENTIFIER
):
action_instances.append(
{
"name": "reference_copy_link",
"params": None,
"caption": "Copy Reference Link",
"description": "This will copy the reference as a string to the clipboard",
"multi_select": False,
}
)

return action_instances

def execute_multiple_actions(self, actions: list, am_base_obj: Any = None) -> None:
def execute_multiple_actions(self, actions: list, **kwargs) -> None:
"""
Executes the specified action on a list of items.

Expand Down Expand Up @@ -170,14 +179,14 @@ def execute_multiple_actions(self, actions: list, am_base_obj: Any = None) -> No
name = single_action["name"]
sg_publish_data = single_action["sg_publish_data"]
params = single_action["params"]
self.execute_action(name, params, sg_publish_data, am_base_obj)
self.execute_action(name, params, sg_publish_data, **kwargs)

def execute_action(
self,
name: str,
params: Any,
sg_publish_data: dict,
am_base_obj: Any = None,
**kwargs,
) -> None:
"""
Print out all actions. The data sent to this be method will
Expand All @@ -193,6 +202,7 @@ def execute_action(
"Execute action called for action %s. "
"Parameters: %s. Publish Data: %s" % (name, params, sg_publish_data)
)
am_base_obj = kwargs.get("am_base_obj")

if name == "create_generic_asset":
# Right click a task the left panel
Expand Down
6 changes: 3 additions & 3 deletions hooks/tk-flame_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class FlameActionError(Exception):
class FlameActions(HookBaseClass):
##############################################################################################################
# public interface - to be overridden by deriving classes
def generate_actions(self, sg_publish_data, actions, ui_area):
def generate_actions(self, sg_publish_data, actions, ui_area, **kwargs):
"""
Returns a list of action instances for a particular publish.
This method is called each time a user clicks a publish somewhere in the UI.
Expand Down Expand Up @@ -136,7 +136,7 @@ def generate_actions(self, sg_publish_data, actions, ui_area):

return action_instances

def execute_multiple_actions(self, actions):
def execute_multiple_actions(self, actions, **kwargs):
"""
Executes the specified action on a list of items.

Expand Down Expand Up @@ -167,7 +167,7 @@ def execute_multiple_actions(self, actions):
params = single_action["params"]
self.execute_action(name, params, sg_publish_data)

def execute_action(self, name, params, sg_publish_data):
def execute_action(self, name, params, sg_publish_data, **kwargs):
"""
Execute a given action. The data sent to this be method will
represent one of the actions enumerated by the generate_actions method.
Expand Down
Loading
Loading