No internet connection
  1. Home
  2. How to

How to get Playhead TC Position and insert as text value in Import Session Data Window

By Matthias Pasedag @Matthias_Pasedag
    2020-04-24 09:32:23.989Z

    Hi there!
    First of all: I started testing SF this week and I am already getting kind of addicted to it - great stuff!
    Constantly new ideas are popping up while working.

    So, I am quite happy with my workflowbased automated Import Session Data Window, as it saves me lots of clicking. There is actually only one thing missing that would make it absolutely perfect for me: inserting the TC Position in my session to the Timecode Mapping Options Textfield.

    So, the plan is to go to the desired TC then drag&drop the AAF/OMF/Session and everything sets itself up incl. the mapped start time to the current TC position in the session timeline (Right now the script marks the minutes position in the field, as I frequently work on minute positions for short material).
    Is there a way to do this?

    Here is the recent script:

    
    sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.elementWaitFor();
    
    sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.popupButtons.first.popupMenuSelect({
        menuPath: ["Map start timecode to"],
    });
    
    sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.textFields.whoseTitle.is('NumericEntryText').first.elementClick();
    sf.keyboard.type({ text: '10:00:00:00' });
    sf.keyboard.press({ keys: 'enter' });
    
    sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Media Options').first.popupButtons.allItems[1].popupMenuSelect({
        menuPath: ["Consolidate from source media"],
    });
    
    sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Import Clip Gain').first.checkboxSet({
        targetValue: "Disable",
    });
    
    sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Import Volume Automation').first.checkboxSet({
        targetValue: "Disable",
    });
    
    sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Only Include Clips on Timeline').first.checkboxSet({
        targetValue: "Enable",
    });
    
    sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Session Data').first.checkBoxes.whoseTitle.is('Pan odd tracks left/even tracks right').first.checkboxSet({
        targetValue: "Enable",
    });
    
    sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.textFields.whoseTitle.is('NumericEntryText').first.elementClick();
    
    sf.keyboard.press({
        keys: "right, right",
    });
    
    sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.elementWaitFor({
        waitType: "Disappear",
        timeout: 120000,
    });
    
    var trackNames = sf.ui.proTools.trackNames.filter(n => n.match(/(Audio)/i));
    
    sf.ui.proTools.trackSelectByName({
        names: trackNames,
        deselectOthers: true,
    });
    
    sf.keyboard.press({
        keys: "ctrl+down",
    });
    

    Many thanks, I am loving this stuff!

    Solved in post #2, click to view
    • 7 replies
    1. Hi @Matthias_Pasedag,

      Great stuff - and happy to hear you're liking SoundFlow already!

      inserting the TC Position in my session to the Timecode Mapping Options Textfield.

      So if I hear you correctly, you want to read the session's current timecode and then insert that value into the "Timecode Mapping Options" text field.

      I think the proper action to use for this is likely a mouse click and keyboard simulation, due to the way Pro Tools handles timecode fields.

      To get the current timecode, fetch it like this before opening the ISD dialog:

      var currentTimecode = sf.ui.proTools.selectionGet().mainCounter.trim();
      

      Then, to fill it in:

      sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.textFields.whoseTitle.is('NumericEntryText').first.elementClick();
      
      sf.keyboard.type({ text: currentTimecode.replace(/:/g, '') });
      
      ReplySolution
      1. Matthias Pasedag @Matthias_Pasedag
          2020-04-24 10:54:12.165Z

          Hi Christian,

          this is perfect if using a shortcut in the first place, thanks! I have a working version with this.
          But what I forgot to mention in the first post and is not seen in the script: I used the ISD window as the trigger, which runs like a charm: drag and drop - BAAM! :)
          I already thought that getting the TC after the ISD window is open might be a problem. So there's no way for getting this to work in combination with the windows trigger, right?

          1. I saw you deleted your comment about getting it to work.
            You should be able to read the main counter, but you may have to wire up a script for it yourself if you can't use the builtin function. I imagine it could fail if the ISD dialog is modal.

            1. Matthias Pasedag @Matthias_Pasedag
                2020-04-24 11:58:28.803Z

                Yes, I tricked my self, because the variable still got the value and didn't change the TC while testing in the first place.
                Alright, thanks for the help! Wiring up a script is probably way ahead of my programming capabilities at this stage - but still great with a shortcut trigger before the drag and drop or, instead with the manual TC adjust as in the original script. :)

                1. Try this if it didn't update the value correctly:

                  sf.ui.proTools.mainWindow.invalidate();
                  var currentTimecode = sf.ui.proTools.selectionGet().mainCounter.trim();
                  
                  1. Matthias Pasedag @Matthias_Pasedag
                      2020-04-24 15:53:19.176Z

                      Wow, actually the script is working now with your first recommendation - just a PT restart later, as it seems. Didn't change anything (I think at least).
                      The trigger is the window focus on ISD, then it runs from here:

                      
                      var currentTimecode = sf.ui.proTools.selectionGet().mainCounter.trim();
                      
                      sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.popupButtons.first.popupMenuSelect({
                          menuPath: ["Map start timecode to"],
                      });
                      
                      sf.ui.proTools.windows.whoseTitle.is('Import Session Data').first.groups.whoseTitle.is('Timecode Mapping Options:').first.textFields.whoseTitle.is('NumericEntryText').first.elementClick();
                      
                      sf.keyboard.type({ text: currentTimecode.replace(/:/g, '') });
                      

                      Works like a charm, awsome!
                      Thanks a lot, Christian!

            2. Matthias Pasedag @Matthias_Pasedag
                2020-04-30 13:19:25.607Z

                Still being extremely happy with the performance of this script with AAF/OMF imports I do have to cook this up once again:
                As I trigger the script with the ISD window opening the settings won't match if I drag and drop a PT session. I think I need to get two different paths of actions depending of the kind of import file. Is there a way to get the info wether it's a AAF/OMF or Current Session out of the "Source Properties" of the ISD window? Or somewhere else?

                It's probably only about the "Type" being "Current Session" to go down as an IF route, right? OMF and AAF would be ELSE.