Get the frame range of a shot from a publishing plugin

Hi,

I am creating a publishing plugin to publish shots with alembic, and I would like to get the frame range for the alembic command from the sg_cut_in and sg_cut_out of the shot in shotgun.

I just wondered if I had to make the script access to the shotgun websit with the API myself, or can I access those fields by another way ?

I hope my question makes sense :slight_smile:

Thank you for your help

Cheers !

2 Likes

If you are using the standard hooks you could do a simple api call for those fields.

sg_filters = [["id", "is", self.parent.context.entity["id"]]]
fields = ["sg_cut_in", "sg_cut_out"]

data = self.shotgun.find_one(sg_entity_type, filters=sg_filters, fields=fields)

Then you can access the data like this:

sg_cut_in = s.get("sg_cut_in")
sg_cut_out = s.get("sg_cut_out")
6 Likes

Thanks a lot for your reply !

Unfortunately I have an error letting me know that my class (inherited from HookBaseClass) has no attribute “context”, do you have an idea how I can fix that ?

2 Likes

Ah yeah Ricardo’s example is close, but your correct the Hook class doesn’t have a context property.

Normally if you want to get the context via a hook you can get it through its parent, so self.parent.context. The parent, in this case, would be the publish Application instance.

(I’ve now edited Ricardo’s example above to fix this.)

However the publish app is a bit special in this regard, so whilst you can get the context with the method mentioned above, there is a more correct way.
If your code is running within a publish plugin, then the item has a specified context as well which may be different to that of the current engine/app’s context. So instead you should be able to get the context via the item’s context property.

5 Likes

Perfect it works perfectly, thanks a lot for your help :slight_smile:

Cheers !

3 Likes