Get name of python object

I’m making some improvements to the collect media script and I’ve run into an issue. The project I’m testing in is throwing an error and I can’t for the life of me figure it out. I know what the issue is but I need to know which reel/reel group is causing it. Other projects are fine so it’s a weird one as I think this is a bit of an edge case.

I’ve tried to debug by spitting out the name at each step but to no avail. Is there a way to call a flame object directly and then get information from there?

In other words, in the console I’m getting flame.PyReel object at 0x7f6f5edacf90 and I’d like to be able to implicitly call that object and get it’s name and parent, etc so I can work backwards.

How are you getting that detail to print?

Ya, normally I would iterate through the selection. Something like this.

import flame                                                                            
                                                                                        
def process_selection(selection):                                                       
    '''Loop through selection.'''                                                       
                                                                                        
    for reel in selection:                                                              
        print(reel)  # that PyReel object stored as a variable named reel                                                             
        print(reel.name)                          
        print(reel.parent)                                                             
                                                                                        
                                                                                        
def scope_reel(selection):                                                              
    '''Filter for only PySequence.'''                                                   
                                                                                        
    for item in selection:                                                              
        if isinstance(item, flame.PyReel):                                              
            return True                                                                 
    return False                                                                        
                                                                                        
                                                                                        
def get_media_panel_custom_ui_actions():                                                
    '''Python hook to add custom right click menu.'''                                   
                                                                                        
    return [{'name': 'WIP...',                                                          
             'actions': [{'name': 'Print PyReel Details',                                
                          'isVisible': scope_reel,                                      
                          'execute': process_selection,                                 
                          'minimumVersion': '2021.1'}]                                  
            }]                                                                                        

example_pyreel_details.py (726 Bytes)

Re-reading your question… Short answer - Im not aware of a way to directly interact with the PyFlame objects. Its all based on selections.

I lied… I mostly use selections but I guess you could interact directly by using the flame module defines. So instead of using selection workflow, you could get the current ReelGroup and then drill down to the PyReel you want with these. But you can see these defines spit out a lot of lists to sift through, I think selection way might be easier.

Flame Module Defines

So maybe for example…

import flame

reel = flame.project.current_project.current_workspace.desktop.reel_groups[0].reels[0]

print(reel)
print(reel.name)
print(reel.parent)

Hey Kyle,

Could you do use something like this?

This example is only searching for desktops in libraries, but if I remember correctly, your Collect Media Script scans almost everything.

def find_an_object(selection):

    libraries = flame.project.current_project.current_workspace.libraries

    placeholder = "flame.PyReel object at 0x7f6f5edacf90"

    for library in libraries:
        for desktop in library.desktops:
            if str(desktop) in placeholder:
                print ("Desktop Name:", desktop.name)
                desktop_parent = desktop.parent
                print ("Parent: ", desktop_parent)
                desktop_grandparent = desktop.parent.parent
                print ("Grand Parent: ", desktop_grandparent)
                desktop_greatgrandparent = desktop.parent.parent.parent
                print ("Great Grand Parent: ", desktop_greatgrandparent)

find_object_test.py (1.1 KB)

Thanks both. Looks like there isn’t really a great way to do it. In the end I just had to debug my way through it and I finally found the culprit. A clip that turned into a sequence that was then returning None for segments.