RV Screening Room read version data

Hi

Is there an easy way to read shotgun version data from sources loaded into a timeline in RV Screening Room?

I have setup an RV package that will just add an overlay to each source played in RV when using RV Screening Room (cut view).
This is basically to overlay the shotgun version name for all sources played in the timeline.

Right now the only missing bit for me is to read the shotgun version name (the file path is not good for me).
So I was wondering if the data is added somehow to the sources by RV Screening room and available via commands in python.

Or if there is a better way to do this?

Many thanks

Jacob

2 Likes

Hi Jacob,

If you are using Shotgun’s Screening Room for RV extension, then there is option called the Shotgun Info Widget that can help with this. I’m attaching a guide below that explains how this works

The widget can be configured to display custom fields from your version entity (such as the version name)

To configure the fields in the Shotgun Info Widget you need to edit your shotgun_fields_config_custom.mu file and add the fields you want to see in the fieldDescriptors area and then set the displayOrder. The displayOrder will show and define the order of fields in the info box while the configs in the fieldDescriptors section will configure the data loading from Shotgun.

Let me know if you have any other questions and I’ll be happy to help.

Cheers,
Andrew

2 Likes

Thanks Andrew

Editing the fields in the Shotgun Widget it’s great. I will really make use of that.

But I was hoping to use the custom overlay I build for displaying the version name only.
The use case would be:

  • Timeline plays with the version name only as overlay (I will default to this when playing the timeline).
  • Our configured Shotgun Widget will display all info when using Shif+I, on demand since it takes over the image to display a fair bit of info.

I could also set the Shotgun Widget to display only the version name and have it on by default, but we would then lose the opportunity to see all of the other info we wish to show on demand for a version.

Hence I was hoping I could access the shotgun version used by the SG widget from my custom overlay package.
I need to figure how to find the version name ( efficiently) or delve into the Shotgun Info widget code to find out, but it was getting a bit tricky so I thought I’d ask.

Thanks a lot for the tips on customizing the Shotgun Widget though.

Thanks

Jacob

1 Like

Hi Jacob,

I think if I’m getting it right, you are really just looking for the metadata on each version. It is stored in a tracking.info variable on the FileSource node.
It is populated asynchronously so beware trying to find it after the source-group-complete event. You are really looking for the graph-state-change event that contains the tracking.info in the event.contents().

In practical terms, this means, some time after you load a Shotgun source (through Shotgun Integration or Screening Room, not SG Review), you can start using some of the shotgun_mode methods.

To do this from Python, you can use rv.runtime.eval.

Here is a bare minimum (ie, no error handling) way of getting the version name.

import rv
rv.runtime.eval("""

shotgun_mode.theMode().versionNameFromSource("%s");

""" % rv.commands.sourcesAtFrame(rv.commands.frame())[0], ["shotgun_mode"])

The shotgun_mode mu module has a function called theMode() which will return the singleton ShotgunMode object. That object has a method called versionNameFromSource where it looks up tracking info on that fileSource to get the version name.

You can dig into plugins/Mu/shotgun_mode.mu for other methods you can call.

Alternatively you can get at the tracking.info yourself, but given the shotgun_* modules likely do everything you want, you can just re-use the shotgun integration/screening room functions.

I hope that helps you build what you are looking to build!

-Kessler

2 Likes

Hey Michael

Thanks a lot for the reply.

I ended up figuring a solution which has worked really well:

def _get_source_shotgun_data(source):
    """
    Get the shotgun data from a source.

    Args:
        source (str): rv source name.

    Returns:
        dict: shotgun data as a dictionary.

    """
    try:
        source_data = rv.commands.getStringProperty(
            "{}.tracking.info".format(source)
            )

        data_list = ast.literal_eval(str(source_data))
    except:
        return {}

    return {k: v for k, v in zip(data_list, data_list[1:])}

Then I saw your post today about this which is extremely useful. I will definitely be digging more into the shotgun_mode.

Loving getting into doing work with RV and SG Screening Room.

Thanks

Jacob

7 Likes

Thanks for sharing your code jacob.
I’ve set this up in our RV source_setup but it’s not returning any data for some reason.
I have SG screening room and integrations enabled, SG Review disabled.
Whereabouts in your source_setup are you calling your _get_source_shotgun_data method from?
Thanks!
Patrick

1 Like

Hi @Patrick ,

Source Setup is going to be a bit too early to run this. Use the switch -debug events when running RV and you’ll find that the property change for which RV is getting the shotgun data happens a little bit after the source is set up.

Is what you are doing able to happen slightly after source-group-complete once the shotgun data is populated?

1 Like

I want to grab data from a SG field to set OCIO context properties.
Can you point me in the right direction to achieve this?
Thanks for the quick reply!
Cheers
p.

1 Like

Aha! It’s finally clicked… when you said “source setup is going to be a bit too early” I thought you meant the entire source_setup.py file… but it made me think… and I realised different methods in that file are triggered under different events. So I was able to obtain tracking.info in the “maybeUpdateViews” method! Wonderful.

One thing that is odd, even though I’m getting the sg fields data in that method, my “Shotgun Info Overlay” isn’t working, either via ctrl+i or via the menu item. Can you think of why that might not be working? (I appreciate this should maybe be under a new thread)

1 Like

Also, in the shotgun_fields_config_standard.my, how would I configure the fieldDescriptor to point to a nested field?; eg:

sg_colour_specification.CustomEntity20.sg_cdl_file.PublishedFile.path

Would it be something like this? :

("cdl",  "CDL", "sg_colour_specification.CustomEntity20.sg_cdl_file.PublishedFile.path",              "text", "Shot", false)
1 Like

I should have tried before posting… that works!

2 Likes

Haha, @Patrick that was a lovely exposition to read though (and legitimately helps others on their path in the future, I love reading those sorts of trains of thoughts when I’m looking for a solution).

Did you add it to the display order for your shotgun info overlay? It uses the display order section to determine what shows up (since you might want lots of data, but not to show it all).

For example, here’s the default display order function:

98 function: displayOrder (string[]; )99 {   
100     string[] fo = string [] {
101         "id",
102         "name",
103         "description",
104         "department",
105         "status",
106         "user",
107         "created",
108         "shot",
109         "shotStatus",
110         "asset",
111         "assetStatus",
112         "mt_Movie",
113         "mt_Frames"
114     };
115 }
1 Like

No, this is entirely seperate to my other quest… the shotgun info overlay doesn’t appear at all!

1 Like

Ok, another interesting question.
So, I’m able to get SG data in the graph-state-change event. But this event is only triggered after the files are loaded in to a session and the file ocio node has been created.
How do I pass any data from the graph-state-change event to the ocio file node attached to the source?
From this event method, I am able to get the group name from the event.contents() eg: sourceGroup000001_source.tracking.info
How would I edit the ocio file node from only this bit of information?
Thanks again!
p.

1 Like

In this case, I’d walk up the group, then back into the pipeline group.

For instance:

sourceGroup = rv.commands.nodeGroup('sourceGroup000001_source')

would give you the outer group that the node is contained in (in this case, it is probably “sourceGroup000001”).

From there, you can use:
lookPipeline = rv.extra_commands.nodesInGroupOfType(sourceGroup, “RVLookPipelineGroup”)[0] # Note, this should probably be error checked.

If it isn’t in the lookPipeline, use the same method but whatever pipeline group you are looking for.

Then, you can use the same nodesInGroupOfType on the pipeline group to find your OCIO node. From there you can change your properties.

You can speed up that process if you get comfortable with extra_commands.associatedNodes(), but if you are doing multiple steps or one to be more explicit about which node you are affecting (for instance, if your pipeline has multiple OCIOFile nodes between Look, Linearize, and Color groups and you want to target a specific one).

This is sort of what the sourceSetup that ships with RV is doing, only on source-group-complete.

1 Like