Publish presets

Sometimes it can be desirable to have different types of Publish presets that your users can choose between.
For example, there maybe situations where you want your users to only output a scene file, and other occasions when you want them to publish a playblast or a material. By default you have one settings block for tk-multi-publish2 in a given environment that collects all of these things and then the user could untick the ones they don’t want:

However, to avoid mistakes and to make it clear for your user’s what you want them to publish for a given type, you could have multiple tk-multi-publish2 settings registered in the same environment so that you have multiple launch actions for the type of publish you want to do:


(Note Shotgun doesn’t provide a publish plugin for publishing materials, this example is purely to illustrate how you could have separate settings/presets/actions for different types of publishes)

You can achieve this by duplicating up your publish settings, and setting a different display_name value for each settings block, that will be used as the action menu name for the publish app.

In the env/includes/settings/tk-maya.yml you would add the app for each settings block:

settings.tk-maya.asset_step:
  apps:
    tk-multi-publish2-scene: "@settings.tk-multi-publish2.maya.asset_step.scene"
    tk-multi-publish2-playblast: "@settings.tk-multi-publish2.maya.asset_step.playblast"
    tk-multi-publish2-alembic: "@settings.tk-multi-publish2.maya.asset_step.alembic"
    tk-multi-publish2-materials: "@settings.tk-multi-publish2.maya.asset_step.materials"
    ...

and then in the env/includes/settings/tk-multi-publish2.yml you would have:

settings.tk-multi-publish2.maya.asset_step.scene:
  display_name: "Publish Scene"
  collector: "{self}/collector.py:{engine}/tk-multi-publish2/basic/collector.py:{config}/tk-multi-publish2/collector.py"
  collector_settings:
      Work Template: maya_asset_work
  publish_plugins:
  - name: Publish to Shotgun
    hook: "{self}/publish_file.py"
    settings: {}
  ...

settings.tk-multi-publish2.maya.asset_step.playblast:
  display_name: "Publish Playblasts"
  ...

settings.tk-multi-publish2.maya.asset_step.alembic:
  display_name: "Publish Alembic"
  ...

settings.tk-multi-publish2.maya.asset_step.materials:
  display_name: "Publish Materials"
  ...

Where each settings block only contained the required plugins for that type of publish.

14 Likes

Ooh… This is handy :o

2 Likes

Related question,

can we give the publish menu item a shortcut?

2 Likes

Ah good question! Toolkit doesn’t support setting shortcuts for the actions, though it sounds like a good feature request.

However you could implement the shortcuts your self, by adding something like the following in the engine_init.py.

if engine.name == "tk-maya":
    import sgtk 
    import pprint 
    from sgtk.platform.qt import QtGui 

    e = sgtk.platform.current_engine() 
    # optionally print the commands so you can get the names
    pprint.pprint(e.commands) 
    # Get the call back for running the Toolkit action.
    loader_callback = e.commands["Publish Alembic..."]["callback"] 
    
    # Use Qt to register a shortcut.
    parent = QtGui.QApplication.activeWindow() 
    shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+L"), parent); 
    
    shortcut.activated.connect(loader_callback)
3 Likes

Hi Philip,
This is a great idea cleans up a lot of the clutter in the UI too.
Question, would it then be better to have a separate collector for each publish type? which would then allow for a separate template for each type as well? or is there a place to put a function call to a class inside the collector for each type?
I havent dove into the collector, or the new publish2 workflow yet so pardon me if this is obvious :D…

-Ross

3 Likes

I’m currently implementing this but I’m making a different collector indeed.
Would be good to know if we can function call.

3 Likes

Good question. It’s kind of up to you really. Since you have different setting blocks for each type of publish you could easily define it to point at a separate collector.

In my example, I just have one collector, which collects everything regardless of which type you are running, but since the plugins only subscribe to certain item types, you only get the publish items for the type you configured.

Having one collector seems like a simpler option, but I could also see the argument for breaking the logic out so that it becomes easier to know which file handles what logic.

2 Likes

Giving that, which functions definately need to be in the collector script?

2 Likes

I think the only ones you must implement, are the process_current_session() and process_file() methods. If you don’t they will raise a NotImplementedError.

2 Likes

Just noticed this doesnt work in the Standalone :disappointed:

Any suggestions how to go about creating separate publishers for Apps that are not pipelineable?
(World Machine for example)

Ideally I want my artist to drag in a folder with world machine files and then write a special collector/hook for that.
Since such folder has “world builder” .tmd files AND comon image files, I’d like these to be published as a bundle.

So ideally when a folder gets dragged in and one file is a .tmd file it should trigger the specific “world Builder” logic. :thinking:

1 Like

When you say it doesn’t work in standalone, how do you mean?
For me I get multiple options in SG Desktop showing up:

2 Likes

Not for me :frowning:

tk-multi-publish2.yml

settings.tk-multi-publish2.standalone:
  display_name: "Publish"
  collector: "{self}/collector.py"
  publish_plugins:
  - name: Publish to Shotgun
    hook: "{self}/publish_file.py"
    settings: {}
  - name: Upload for review
    hook: "{self}/upload_version.py"
    settings: {}
  help_url: *help_url
  location: "@apps.tk-multi-publish2.location"

  settings.tk-multi-publish2.standalone.worldmachine:
  display_name: "Publish World Machine"
  collector: "{self}/collector.py"
  publish_plugins:
  - name: Worldmachine Publish
    hook: "{self}/publish_file.py"
    settings: {}
  - name: Upload for review
    hook: "{self}/upload_version.py"
    settings: {}
  help_url: *help_url
  location: "@apps.tk-multi-publish2.location"

tk-desktop2.yml

# project
settings.tk-desktop2.all:
  apps:
tk-multi-launchapp: "@settings.tk-multi-launchapp"
#tk-multi-launchhiero: "@settings.tk-multi-launchapp.hiero"
#tk-multi-launchmari: "@settings.tk-multi-launchapp.mari"
#tk-multi-launchmotionbuilder: "@settings.tk-multi-launchapp.motionbuilder"
tk-multi-publish2: "@settings.tk-multi-publish2.standalone"
tk-multi-publish2-worldmachine: "@settings.tk-multi-publish2.standalone.worldmachine"
  location: "@engines.tk-desktop2.location"
1 Like

It might just be from copying an pasting, but I can see some indentation issues.

  1. In tk-multi-publish2.yml the settings.tk-multi-publish2.standalone.worldmachine: is indented when it shouldn’t be.
  2. In tk-desktop2.yml the engine location location: "@engines.tk-desktop2.location" is indented under the publish app.

Also your’ modifying tk-desktop2 are you trying to get this to work in SG Create, I’ve not tried that? :thinking: tk-desktop.yml is for SG Desktop.

1 Like

Yeah from copying, I don’t know how you guys are able to fancily copy your code in here :stuck_out_tongue:

Ah… tk-desktop2 is for Create?.. why is it not caled tk-create? :confused:

2 Likes

Yeah it is a bit confusing. Essentially SG Create might at some point in the future replace SG Desktop, so tk-desktop2 is an evolution on that engine. However at present we are supporting the two in parallel.

1 Like

Ah okay, I had my suspicion when that started to have app launchers.
Interesting, I think I would love to see what exactly that would look like down the line.

Anyway, still no luck :frowning:


1 Like

Yeah I can’t see any issues there, it looks all good to me.
What are you seeing in SG Desktop? Do you get any publish launcher icons?
Are you getting any errors/warnings in the logs?

1 Like

I lied… there are now 2 publishers :smiley:

Sorry! :see_no_evil:

2 Likes

I dont imagine theer is a way to change the icon? :stuck_out_tongue:

2 Likes

I thought you might ask that, :stuck_out_tongue: I quickly looked, but the Publish app hard codes the icon to its provided one unfortunately.

1 Like