No internet connection
  1. Home
  2. How to

How to use Search Markers with Selection Memory Locations?

By alex alcanjim @alex_alcanjim
    2020-09-03 18:18:24.580Z

    I'm trying to use "Search Markers" feature but it seems that only works with common markers. It doesn't work if I use "Selection Memory Locations" as I do.

    Any idea about how to make it works? Thanks!

    • 8 replies
    1. Hi Alex,

      Thanks for asking here.

      As you've noted, we filter out Selection Memory Locations from the Search Markers feature.
      You can't get 100% the same behavior with this script, but close enough, this would allow you to search the current memory locations in your session, including Selection types:

      
      function getMemoryLocations() {
      
          sf.ui.proTools.appActivate();
          sf.ui.proTools.mainWindow.elementRaise();
          var i = 0;
          while (i++ < 5) {
              if (!sf.ui.proTools.memoryLocationsWindow.invalidate().exists) {
                  sf.ui.proTools.getMenuItem('Window', 'Memory Locations').elementClick({}, 'Could not click to open Memory Locations window');
                  sf.ui.proTools.memoryLocationsWindow.elementWaitFor();
              }
              var table = sf.ui.proTools.memoryLocationsWindow.invalidate().tables.first;
              if (!table.exists) {
                  sf.ui.proTools.memoryLocationsWindow.windowClose();
              }
          }
          if (!table.exists) throw 'Could not find memory locations table';
          var seed = (new Date).valueOf();
          var items = [];
          table.children.forEach(function (item, i) {
              var num = item.children[0].children[0].title.value;
              var text = item.children[1].children[0].title.value;
              if (num === null || text === null) return;
              items.push({
                  name: num,
                  num,
                  text,
              });
          });
          return items;
      }
      
      var num = sf.interaction.popupSearch({
          items: getMemoryLocations(),
          columns: [
              { name: 'Number', key: 'name', width: 20, },
              { name: 'Text', key: 'text', width: 80, },
          ],
      }).item.num;
      
      sf.ui.proTools.appActivate();
      sf.ui.proTools.mainWindow.elementRaise();
      
      sf.ui.proTools.memoryLocationsGoto({ memoryLocationNumber: Number(num) });
      
      1. A
        In reply toalex_alcanjim:
        alex alcanjim @alex_alcanjim
          2020-09-03 20:02:36.533Z

          Wow!! Sounds awesome!

          I’ll try it ASAP!

          Thanks so much for your help!

          1. A
            In reply toalex_alcanjim:
            alex alcanjim @alex_alcanjim
              2020-09-04 11:23:02.730Z

              Hi Christian!

              I've tried this new code and something doesn't works correctly.

              First of all, it only works if Memory Locations Window is closed before running the command. Maybe It would be usefull to make "force close Memory Location Window" before the script.

              After that, once the "Search dialog" appears, when you type any text finding a memory location, the Search Window doesn't shows any result.

              Could you please check it?

              Thanks so much in advance for your help!

              1. Hi Alex,

                Can you show us a screenshot of the text you're typing when you search and of the search dialog with the content? It's likely that you're searching for something that the search algorithm doesn't support.

                1. Aalex alcanjim @alex_alcanjim
                    2020-09-14 14:00:00.745Z

                    Hi Christian,

                    Just trying to figure out what is happening. Here you can find some screenshots.

                    Here you can see my Memory Location list and the "Search Box" opened. When I try to search any Memory Location by name, nothing happens. Here comes a screenshot as example.

                    But, if I try to search by number, It seems like the script is working perfectly. Here comes and example:

                    It seems like the "Search engine" is only looking on Memory Location number and not on the Memory Location name.

                    Is there any way to make it works using Memory Location names?

                    Thanks so much in advance for your help!

                    1. My apologies - please try this instead:

                      
                      function getMemoryLocations() {
                      
                          sf.ui.proTools.appActivate();
                          sf.ui.proTools.mainWindow.elementRaise();
                          var i = 0;
                          while (i++ < 5) {
                              if (!sf.ui.proTools.memoryLocationsWindow.invalidate().exists) {
                                  sf.ui.proTools.getMenuItem('Window', 'Memory Locations').elementClick({}, 'Could not click to open Memory Locations window');
                                  sf.ui.proTools.memoryLocationsWindow.elementWaitFor();
                              }
                              var table = sf.ui.proTools.memoryLocationsWindow.invalidate().tables.first;
                              if (!table.exists) {
                                  sf.ui.proTools.memoryLocationsWindow.windowClose();
                              }
                          }
                          if (!table.exists) throw 'Could not find memory locations table';
                          var seed = (new Date).valueOf();
                          var items = [];
                          table.children.forEach(function (item, i) {
                              var num = item.children[0].children[0].title.value;
                              var text = item.children[1].children[0].title.value;
                              if (num === null || text === null) return;
                              items.push({
                                  name: num + ' ' + text,
                                  num,
                                  text,
                              });
                          });
                          return items;
                      }
                      
                      var num = sf.interaction.popupSearch({
                          items: getMemoryLocations(),
                          columns: [
                              { name: 'Number', key: 'num', width: 20, },
                              { name: 'Text', key: 'text', width: 80, },
                          ],
                      }).item.num;
                      
                      sf.ui.proTools.appActivate();
                      sf.ui.proTools.mainWindow.elementRaise();
                      
                      sf.ui.proTools.memoryLocationsGoto({ memoryLocationNumber: Number(num) });
                      
                      1. TTim Miller @Tim_Miller
                          2022-04-25 15:15:15.169Z

                          Hello Christian!

                          This script only works for me if the Memory Locations window is closed before running it. I like to keep mine open, so is there a way to run this script where it will look to see if the memory locations window is already open then pull up the search window?

                          I cut SFX/BGs/Foley for feature films and if I can get this script to work, it would be a HUGE time saver for me!

                          Tim

                          1. TTim Miller @Tim_Miller
                              2022-04-25 15:28:33.552Z

                              or just have it close the memory locations window after the search is complete? Otherwise I just get a glitch where the search box will quickly open/close and disappear if the memory locations window is already open.