Publish2 customization question

Hey all,

I’m attempting to add an Asset publish item task, leveraging the out-of-the-box hook.

I created:


…where the first is equivalent to, and the second is similar except the internals write out an Arnold standin rather than an Alembic, and both have class names that indicate what they do.

I’ve also modified ..\config\env\includes\settings\tk-multi-publish2.yml in the Maya asset step section to trigger the correct hooks, and have added publish template paths for each in ..\config\core\templates.yml.

Lastly there are some UI tweaks, screencap for clarification:

The issue I’m running into currently, is that when I test with Validate, both the Publish Alembic and Publish Arnold Standin tasks are showing that they’ll resolve the output file path and naming to be whatever is described in the asset_arnold_standin template publish definition, which is wrong for alembics.

From testing, it seems that whatever the order of publish plugins is in tk-multi-publish2.yml that resolve as a child of a given item in the UI (here All Session Geometry), the one that comes last is the publish template that ends up getting used for both (e.g. if I switch it so that A follows B, the publish template for both ends up being the asset_alembic_cache definition from templates.yml, which will be wrong for Arnold standins). Also, if I eliminate one or the other, I get the desired results specific to the one that remains.

At this point, advice is appreciated.




Hi @deanareeno

Interesting. I think we would need to see your plugins to be sure. But are you storing the path you want to publish on the item like we do here?

If so then both plugins will be overwriting the same setting, I think you would want to use local_properties instead so that both plugins don’t overwrite each other.


I think you could add extra properties to your geom_item in collector. e.g.:["ass_publish_path"] = asset_arnold_standin_path["abc_publish_path"] = asset_alembic_cache_path

and use these pathes in your plugin by assigning it’s value to item.properies[“path”] in Publish method.


For some yet-to-be-ascertained reason, all of the plugin items in the All Session Geometry stack are inheriting values on common properties based on the values of the last item through the stack, so I have been unable to use e.g.["path"] and the like. For the same reasons item.local_properties hasn’t been effective for me.

I’m not subclassing the collector hook at all, but what @ymesh suggested gave me an idea for a different implementation.

Now I’m creating uniquely named item properties in each of my subclassed publish_session_geometry hooks (e.g.["publish_template_alembic"] in that subclass), and when each is instanced on a Publish invocation, there’s no clashing/overwriting of values across items in the stack. In the methods of each subclass I had to change it so they’re only concerned with the keys unique to their subclass when returning values.

I also had to create relative publish_file hook subclasses so that their methods are also only concerned with the aforementioned unique keys/values:


…and my hook definitions in tk-multi-publish2.yml look like e.g.:

hook: "{self}/{config}/tk-multi-publish2/{config}/tk-maya/tk-multi-publish2/basic/"

The upshot of all this is that I’m getting expected results: creation & in-place publishes of ABC & ASS files from the correct disk loactions, validation, correct post-publish SG Publish UI button triggers, etc.

This screencap is of a successful Validate run through the SG Publish UI:

Having said all of this, while it’s all “working” now, I would prefer to understand why the stack items are behaving the way they are for me such that I needed to implement something that feels like a workaround rather than an “as-the-developers-intended” solution.


1 Like

I just tried the item.local_settings on my side, but it’s working for me.
I created two near identical simple plugins that both stored their paths in the accept method and then retrieved them in the publish method: (1.2 KB) (1.2 KB)

Which resulted in the two paths being correctly logged:

1 Like

Cool, now try subclassing the SG provided hook into 2 new hooks like I mentioned in the OP & let me know how it goes.

1 Like

So that you’re leaving the template to be set in the rather than in your inherited plugins?
I’ll have to have a look tomorrow.

1 Like

So I took a look at the, but I’m not sure what exactly you are overriding in your custom plugins.
The hook is using rather than item.local_properties so if that behaviour is not being overridden then it will continue to overwrite the property for each plugin, since it will be storing it as a global value on the item rather than as a plugin specific value.

I guess ultimately it would be better if our hook used local_properties by default as that would mean you wouldn’t need to override that behaviour.

One slightly hacky thing you could do to avoid having to implement the full publish logic in your hook, is to override the publish method, set the["publish_template"] = ... and then call super.

I mocked up another example where both plugin 1 and 2 derive from plugin base.

Plugin base uses the like the does, but each derived plugin sets that property before calling the base method so that it is redefined for each plugin when it comes to use it.

Still the better approach would be to use local_settings but I appreciate that would mean taking over more of the base hook logic.

1 Like