Python script to import a .mov from the filesystem to a reel on the desktop

Hello Pythonics,

I’m trying to figure out the code to do the following:

  1. Rt click on a reel in the desktop
  2. Import a clip from a filesystem (path baked in to the script)
  3. Have the clip appear on that reel
  4. Add a TL FX to the clip.

I know the code to import a clip to a library. It’s the reel that I right clicked on that is stumping me. Any suggestions?

1 Like

This might do what you’re looking for:

def import_to_reel(selection):
    import flame

    # Path to quicktime

    import_path = '/some/path/cool_movie.mov'

    # Get selected reel

    import_reel = [reel for reel in selection][0]

    # Import clip to reel

    imported_clip = (flame.import_clips(import_path, import_reel))[0]

    # Open clip as sequence to add timelinefx

    sequence = imported_clip.open_as_sequence()

    # Add timelinefx

    sequence.versions[0].tracks[0].segments[0].create_effect('Blur')

def scope_reel(selection):
    import flame

    for item in selection:
        if isinstance(item, flame.PyReel):
            return True
    return False

def get_media_panel_custom_ui_actions():

    return [
        {
            'name': 'Import...',
            'actions': [
                {
                    'name': 'Import to Reel',
                    'isVisible': scope_reel,
                    'execute': import_to_reel,
                },
            ]
        }
    ]

2 Likes

Have I told you, lately, that I love you?

3 Likes

Mike, I got one more for you. I’m doing this to make slates. I know how to use pyTime and the command to execute a hotkey to make cut points. I want to cut the clip into 3 segments and put a text TL FX on the middle segment. Can you use Python to select a segment at a given timecode?

1 Like

seems like it should be possible… please hold…

2 Likes

yea… so if you cut the clip up after this line:

sequence = imported_clip.open_as_sequence()

you could then change this line:

sequence.versions[0].tracks[0].segments[1].create_effect('Blur')

Changing segments[0] to segements[1] should add the timelinefx to the second segment in the clip

1 Like

Dude. This is so great. I learned Python with batch and the syntax for how to work with clips/reels has been difficult for me to pick up. This is extremely helpful! The next time I see you dinner is on me!

2 Likes

Now THAT’S service.

90 minutes for Python script knowledge? Amazing.

Will script for food

4 Likes

Hey Mike,

When I run the script (the orig you posted) I get this error:

Invalid Entry.
Import to Reel execute callback [<function import_to_reel at 0x7f630a696ef0>((<flame.PySequence object at 0x7f72edb306c0>,),)] failed because of an error of type ‘Invalid Entry.’

Any ideas what this might mean?

Thx,

Andy

Hi Mike and Andy

I found this script very useful and wanted to try adding it to timelineFX, a saved text preset. How could I add this? I tried to do it that way but to no avail.

Thanks

Wilton

 sequence.versions[0].tracks[0].segments[0].create_effect('Text')

    for tlfx in segments.effects:
        if tlfx.type == "Text":
            tlfx.load_setup("/opt/Autodesk/shared/python/slate/template_slate_16x9.ttg")
        else:
            print ("No Text")

Wilton, does the script import the movie for you? I’m getting that error I listed above.

Yes, the movie file with the text attribute.
The only error is related to the “for” that I put right below, but it doesn’t interfere with the rest of the script.
(Flame 2022.1 / Linux)

What version of flame are you running?

2022.2

I just gave it a shot here in 2022.2 and it worked. Does it import the clip? or are you getting this error before it even does the import? If so… maybe something is wrong with the path or the clip itself.

It’s before it imports the clip. Let me check that. I thought I copy/pasted it.

Hey Wilton

give this a try:

tlfx = sequence.versions[0].tracks[0].segments[0].create_effect('Text')
tlfx.load_setup('/opt/Autodesk/shared/python/slate/template_slate_16x9.ttg')
1 Like

Aha! I was rt-clicking in the reel on the desktop, not in the media panel. If I rt-click in the media panel it works. Any way to get it to work on the desktop reel? I didn’t think that was different. Or maybe it’s a bug?

BOOM! This is doing EXACTLY what I wanted!! Thank you!!!

1 Like