Hooks: copy current timecode to clipboard

Credits: Credits and thanks to Lewis Saunders for the ‘copy to clipboard’ cool QT trick and Franck Lambertz for the case2 script (from a timeline)

Two scripts: one for selecting a clip or sequence on a reel or in the media panel, the other one to click on a segment in timeline view. Both will copy the current timecode to the clipboard.

Case 1: From a reel or the media panel:
Right-click on a clip or a sequence and execute the script: Copy TC to Clipboard -> From reel or media panel
This will copy the current timecode (at playhead’s position) to the os clipboard. You can then paste it as text in an email or a text file.

Script link


# Stefan Gaillot
# xenjee@gmail.com
# 2019/09/02
# sg_TC_to_Clipboard_in_MediaPanel.py

# Credits: The clipboard cool QT trick is from Lewis Saunders

''' From a reel or the media panel,
right-click on a clip or a sequence and execute the script: Copy TC to Clipboard -> From reel or media panel
This will copy the current timecode (at playhead position) to the os clipboard.
You can then paste it as text in an email or a text file ...
'''


def scope_object(selection):
    import flame
    for item in selection:
        if isinstance(item, (flame.PySequence)) or isinstance(item, (flame.PyClip)):
            return True
    return False


def sequence_current_tc_to_clipboard(selection):
    import flame
    from PySide2 import QtWidgets

    for item in selection:
        if isinstance(item, (flame.PySequence)) or isinstance(item, (flame.PyClip)):
            clip_or_sequence = item
            print "Current Timecode: ", clip_or_sequence.current_time

    # This clipboard cool trick from Lewis Saunders.
    qt_app_instance = QtWidgets.QApplication.instance()
    qt_app_instance.clipboard().setText(str(clip_or_sequence.current_time))


def get_media_panel_custom_ui_actions():
    return [
        {
            "name": "Copy TC to Clipboard",
            "actions": [
                {
                    "name": "From reel or media panel",
                    "isVisible": scope_object,
                    "execute": sequence_current_tc_to_clipboard,
                }
            ]
        }
    ]




Case 2: From the timeline view of a sequence or a clip:
Right-click on a segment and execute the script: Copy TC to Clipboard -> From a Timeline This will copy the current timecode (at playhead position) to the os clipboard. You can then paste it as text in an email or a text file …

Mostly an extract from this script from Franck Lambertz, plus Lewis Saunders ‘copy to clipboard’ part.

right-click on a segment and execute the script: Copy TC to Clipboard -> From a Timeline This will copy the current timecode (at playhead position) to the os clipboard. You can then paste it as text in an email or a text file …

Script link


# Stefan Gaillot
# xenjee@gmail.com
# 2019/09/02
# sg_TC_to_Clipboard_in Sequence.py

# Credits: Based on FL_Frame_info from Franck Lambertz and 'copy to clipboard' from Lewis Saunders

''' From within the timeline view of a sequence or a clip,
right-click on a segment and execute the script: Copy TC to Clipboard -> From a Timeline
This will copy the current timecode (at playhead position) to the os clipboard.
You can then paste it as text in an email or a text file ...
'''


def scope_timeline(selection):
    import flame
    for item in selection:
        if isinstance(item, flame.PySegment):
            return True
    return False


def current_tc_to_clipboard(selection):
    import flame
    from PySide2 import QtWidgets
    # count idea and code from Franck Lambertz
    s = selection[0]
    parents_count = 0
    my_clip = s

    # While loop from Franck Lambertz
    while not isinstance(my_clip, flame.PyClip) and not isinstance(my_clip, flame.PySequence):
        parents_count += 1
        # print "my_clip: ", my_clip.name, type(my_clip)
        if parents_count == 10 or not my_clip.parent:
            print "Error, can't find the clip info"
            return
        my_clip = my_clip.parent

    clip_or_sequence = my_clip
    sequence_current_tc = clip_or_sequence.current_time.get_value().timecode
    print "Current Timecode: ", sequence_current_tc

    # This clipboard trick from Lewis Saunders
    qt_app_instance = QtWidgets.QApplication.instance()
    qt_app_instance.clipboard().setText(sequence_current_tc)


def get_timeline_custom_ui_actions():

    return [
        {
            "name": "Copy TC to Clipboard",
            "actions": [
                {
                    "name": "From a Timeline",
                    "isVisible": scope_timeline,
                    "execute": current_tc_to_clipboard,
                }
            ]
        }
    ]




2 Replies to “Hooks: copy current timecode to clipboard”

    1. Hi Cyliong,
      Pleasure bud. Not sure of what you’re after exactly but for what i’m understanding it sounds doable.
      Sorry i don’t have much time to try things these days, i’ll keep you posted if i get some time to look into it.
      Good luck and have fun.
      Cheers

Leave a Reply