No internet connection
  1. Home
  2. Macro and Script Help

How to write an "exclude memory locations with this name"

By Jake Carter @Jake_Carter
    2022-11-02 18:10:54.591Z2022-11-02 18:58:23.878Z

    After I cue an episode I create Guide regions from the markers. Similar to a =scene= track but more accurate and custom to my work flow.

    I want to create a macro to do this for me but I’m not sure how to get around my door sweep markers. Can I create an action that will skip over markers with “sweep" & "walla" in the name?

    The last question for this script, could you help me add an action that will repeat the process through a video track, a selection or time code? Right now I am simply entering a number for repetitions.

    The photo is my current macro.

    Here's an example of the problem I want to fix.

    Solved in post #5, click to view
    • 7 replies
    1. samuel henriques @samuel_henriques
        2022-11-02 20:12:42.533Z

        Hello Jake,
        A few questions, any reason consolidate clips is better than create clip group in this case?
        Why did you skip marker Plane?
        Would it be good if the consolidated(or clip group) gets the starting marker name?
        What are all the keywords you want to exclude?

        1. JJake Carter @Jake_Carter
            2022-11-02 20:53:27.597Z

            Hey Samuel,

            Thanks for getting back so quickly.

            @Owen_Granich_Young is my show supervisor and recommended bringing this to you.

            Great suggestion, we can definitely use clip grouping as that would be faster.

            I plan to run the script twice, once on each guide track for checker boarding. If I start guide A on first marker and guide B on second marker I should naturally get a checkerboard. But this is my simple train of thought. If you have a better approach by all means.

            Words to omit: "fade", "SPLIT", "walla", "sweep"

            1. JJake Carter @Jake_Carter
                2022-11-02 21:29:32.394Z

                I need clip groups to end at "black", "RING", & "Main Title" but no clip group to be generated from markers with that name. This seems like a complicated ask so I plan to go through and clear groups generated at these spots as there aren't many. But if you have something up your sleeve for that I figured I would share.

                1. samuel henriques @samuel_henriques
                    2022-11-02 21:56:30.670Z

                    I made it so it works on an initial user selection. I figured if you only need to do a small portion, the script doesn't go back to start.

                  • In reply toJake_Carter:
                    samuel henriques @samuel_henriques
                      2022-11-02 21:44:18.832Z

                      Cool,
                      Select two guide tracks and make a selection to create guide clips.
                      On the first line you can add or remove more words.

                      // Illegal words
                      const illegalInName = ["fade", "SPLIT", "walla", "sweep"]
                      /**
                       * @param {object} selection - initial user selection
                       */
                      const getLegalMemLocs = (selection) => sf.proTools.memoryLocationsFetch().collection['List'].filter(m =>
                          !illegalInName.some(illegal => m.name.toLowerCase().includes(illegal.toLowerCase())) &&
                          m.mainCounterValue >= selection.selectionStart &&
                          m.mainCounterValue <= selection.selectionEnd
                      );
                      
                      
                      function timeCounter() {
                          // get current counter
                          const mainCounter = sf.ui.proTools.getCurrentTimecode().stringValue
                      
                          let originalTimeCounter
                          /// Bars Beats .  
                          if (mainCounter.includes("|")) originalTimeCounter = "Bars|Beats"
                          //  Min Secs .    
                          else if (mainCounter.includes(":") && mainCounter.includes(".")) originalTimeCounter = "Min:Secs"
                          //  Time code
                          else if (mainCounter.split(":").length == 4) originalTimeCounter = "Timecode"
                          //  Feet+Frames
                          else if (mainCounter.includes("+")) originalTimeCounter = "Feet+Frames"
                          //  Samples.     
                          else originalTimeCounter = "Samples"
                      
                          return originalTimeCounter
                      }
                      
                      
                      
                      function clipRename(newName) {
                          sf.ui.proTools.menuClick({ menuPath: ['Clip', 'Rename...'] });
                          const renameWin = sf.ui.proTools.windows.whoseTitle.is('Name').first
                          renameWin.elementWaitFor({}, 'Name Win didn\'t open')
                          const nameClipOnlyButton = renameWin.groups.whoseTitle.is('Name').first.radioButtons.whoseTitle.is('name clip only')
                          if (nameClipOnlyButton.exists)
                              nameClipOnlyButton.first.checkboxSet({
                                  targetValue: "Enable",
                              });
                          renameWin.groups.first.textFields.first.elementSetTextFieldWithAreaValue({
                              value: newName
                          });
                          renameWin.buttons.whoseTitle.is('OK').first.elementClick();
                      };
                      
                      /**
                       * @param {number} startN
                       * @param {number} endN
                       */
                      function selectBetween(startN, endN) {
                          sf.ui.proTools.memoryLocationsGoto({ memoryLocationNumber: startN });
                          sf.ui.proTools.memoryLocationsGoto({ memoryLocationNumber: endN, extendSelection: true });
                      };
                      
                      
                      function main() {
                      
                          sf.ui.proTools.invalidate();
                          const selectedTracksH = sf.ui.proTools.selectedTrackHeaders
                          if (selectedTracksH.length > 2) { alert("Please select the two guide tracks only."); throw 0 }
                      
                          const [guideA, guideB] = selectedTracksH
                      
                          const originalTimeCOunter = timeCounter();
                          sf.ui.proTools.mainCounterSetValue({ targetValue: "Samples" });
                          const originalSelection = sf.ui.proTools.selectionGetInSamples();
                          const legalMemLocs = getLegalMemLocs(originalSelection)
                      
                      
                          try {
                              for (let i = 0; i < legalMemLocs.length; i++) {
                      
                                  const memLocName = legalMemLocs[i].name
                                  const lastI = legalMemLocs.length - 1
                                  if (i === lastI) break;
                      
                      
                                  if (i % 2 === 0) { guideA.trackScrollToView(); guideA.trackSelect() }
                                  if (i % 2 !== 0) { guideB.trackScrollToView(); guideB.trackSelect() }
                      
                                  selectBetween(legalMemLocs[i].number, legalMemLocs[i + 1].number);
                      
                                  sf.ui.proTools.menuClick({ menuPath: ["Clip", "Group"] });
                      
                                  clipRename(memLocName);
                      
                              };
                      
                          } catch (err) {
                              throw err
                          } finally {
                              // Set original user setings and selection
                              sf.ui.proTools.trackSelectByName({ names: selectedTracksH.map(th => th.normalizedTrackName) });
                              sf.ui.proTools.selectionSetInSamples({ selectionStart: originalSelection.selectionStart, selectionEnd: originalSelection.selectionEnd });
                              sf.ui.proTools.mainCounterSetValue({ targetValue: originalTimeCOunter });
                          }
                      
                      }
                      
                      main();
                      
                      Reply1 LikeSolution
                      1. samuel henriques @samuel_henriques
                          2022-11-02 21:50:17.686Z

                          Just updated, fixed typo.

                          1. JJake Carter @Jake_Carter
                              2022-11-02 21:57:08.891Z

                              This code RIPS!
                              Works like a charm! Better than I hoped
                              I so appreciate it! :D

                              Thanks Samuel!

                      2. Progress
                      3. J@Jake_Carter closed this topic 2022-11-02 22:00:11.115Z.
                      4. J@Jake_Carter reopened this topic 2022-11-02 22:00:20.992Z.