I'm fetching and parsing all plug-in names from the plugins selector.
var insertItems = popupMenu.menuFetchAllItems()
is there a way to just grab the items from the first level of the insert menu popup?
I just want the circled menu. Fetching all menu items returns almost 2000 entries.

- Christian Scheuer @chrscheuer2020-10-27 16:25:20.437Z
As a means to speed it up or because you only need to display the first level somewhere?
The 2nd thing is possible via a filter, the 1st thing not.Chris Shaw @Chris_Shaw2020-10-27 17:11:43.765Z
I’d like to get the items at the end of a path. Specifically Plug-ins > Avid or Plug-ins > EQ
Christian Scheuer @chrscheuer2020-10-28 11:00:12.717Z
This here builds a map of just the first 2 levels of menus:
let allMenuItems = sf.ui.proTools.selectedTrack.insertSelectorButtons[0].popupMenuFetchAllItems().menuItems; let menus = {}; allMenuItems.map(mi => menus[mi.path.slice(0, 2).join(':::')] = mi.path); let twoLevelPaths = Object.keys(menus).map(k => menus[k].slice(0, 2)); log(twoLevelPaths);
Christian Scheuer @chrscheuer2020-10-28 11:01:09.239Z
I'm not quite sure what you need it for though? You can't click these.
Chris Shaw @Chris_Shaw2020-10-28 15:07:38.505Z
I’m trying to speed up my insert plugins package script. To get the track width, I fetch all of the plugin menu entries and search for the first entry with a “(“. This usually is the first entry in the EQ menu and 99.9% of the time is followed by the channel width of the insert slot: (mono), (stereo), etc.
Currently I’m grabbing ALL entries of the plugin menu and mapping the paths. I’ve timed it: it can take up to 1.3 seconds in some instances which isn’t too bad but it think it could be much faster especially when inserting across multiple tracks. If I could just grab and map the entries in the EQ menu the process should be much faster.Christian Scheuer @chrscheuer2020-10-28 17:23:21.928Z
That's why my first question was if this was a speed thing:
As a means to speed it up or because you only need to display the first level somewhere?
The 2nd thing is possible via a filter, the 1st thing notChris Shaw @Chris_Shaw2020-10-28 17:54:28.062Z
Sorry about that. Yes. I shortened the map routine which shaves ~ 500- 700ms from my script (see solution below).
Thanks for the help as always!
- In reply tochrscheuer⬆:
Chris Shaw @Chris_Shaw2020-10-28 16:42:41.452Z
I'm assuming that there's no way around fetching all items. Is possible to map only the first 20 or so entries? I can get what I need from just the first few in
allMenuItems
.
Afor
loop instead ofObject.keys(menus).map(k => menus[k].slice(0, 2));
perhaps?(Looks like I just answered my own question… 🤦♂️. I just need to figure out the syntax I guess.)
Chris Shaw @Chris_Shaw2020-10-28 17:17:12.430Z2020-10-28 19:44:12.132Z
Ok. I think this does what I'm looking to do:
Thoughts?function getInsertWidth() { let allMenuItems = sf.ui.proTools.selectedTrack.insertSelectorButtons[0].popupMenuFetchAllItems().menuItems; for (var i = 0; i < 100; i++) { if (String(allMenuItems[i]).includes("(")) { var width = String(allMenuItems[i]).slice(String(allMenuItems[i]).lastIndexOf('(') - 1); if (width.includes('/')) width = width.split('/')[0] + ")" break; } } sf.ui.proTools.appActivateMainWindow(); return width } log(getInsertWidth())
- TTristan Hoogland @Tristan
Hey Chris & Chris
Any tips on speeding up the fetch menu items function when opening the plugins menu based on a string? In my case I'd be looking to simply use any plugin that contains "UAD" at the start. @Kitch mentioned to me the other week in the studio that he thinks we could speed up my menu hang, which feels pretty long in big sessions with the script I've got going (about 1 second per plugin instance that I swap out, which could be in the 30-40 category depending on the session!). I'm assuming based on Chris' above that I might be in luck, but unfortunately I can't just keep it to the top 100 items as they're all elsewhere in the menu, and I don't want to rely on the possibility of everyone not having both "category and manufacturers" enabled.
Thanks!
Kitch Membery @Kitch2022-11-28 09:01:20.456Z
@Tristan_Hoogland I may have misled you into thinking your script could be sped up.
Right now afaik, there is no way to speed up the
popupMenuFetchAllItems()
method as it has to scrape all the information for each of the menu items, which I believe is where things are taking so much time in your script.I had an Idea in mind that might have worked but then realized that it relied on being able to get the channel width of the open UAD plugin. Unfortunately, looking closer at the insert button, insert selector button and other elements in the plugin window there does not seem to be a way to determine this without using the
popupMenuFetchAllItems()
method. agggghhhThere may be a way to slightly improve the speed of your current script with some refactoring though, but not by a significant amount. Sorry If I got your hopes up on this.
If you could add a link here to the other thread for this I'll see if I can have a look for speed improvements.
Brenden @nednednerb
Is it fetching all items every single time a process is run? What about running it once at script start and filing the whole list into an object for SoundFlow? On future runs, it might be faster to get to the plug-ins from that object than to run the fetch menu again. In one session, the plug-in list probably won't change, and scraping the required info from the text object might overcome the need to scan the file system/folders again. Just a random idea...
- TTristan Hoogland @Tristan
Replying to both you and @Kitch ! (Sorry for just liking your post and leaving you without response, Kitch - was straight into mixing lol).
Don't stress at all, it's a pretty powerful script as is and this is a minor gripe in the grand scheme of things. I'm about to go through with a fine tooth comb to see what opportunities I have to speed up with some refactoring, but ultimately the fetch is really the only place the process doesn't feel snappy (the rest is great!).
Brenden, you're right. Currently the way the script works it goes through the process of fetching for each instance. It was always my intention to come back after reaching a proof of concept and then try explore something along the lines of what you're talking about.
I don't know if it gets complicated when trying to manage multichannel, multi-mono and single mono instances as they appear throughout the replacement/scanning process.
I'm still in elementary school with objects, so an elegant solution like you're talking about is probably out of reach for me at the minute. Any suggestions welcome, but I'll do some of my own homework this week and see what I can arrive at.
- In reply tonednednerb⬆:
Kitch Membery @Kitch2022-11-28 21:34:07.242Z
Doing just that is perfect in many situations, however, for @Tristan_Hoogland's script, he needs to find the menu path of the open plugin and also the width of the current plugin, which can only be determined by checking the popup menu each time.
But great input, Brendan!