No internet connection
  1. Home
  2. How to

Remove Markers by Name

By alex alcanjim @alex_alcanjim
    2021-07-28 09:04:06.018Z

    Hi all!

    I'm just looking for a script that allow me to remove every marker which containing "Location" on their name.

    Any idea?

    Thanks in advance for helping!

    Solved in post #2, click to view
    • 4 replies
    1. samuel henriques @samuel_henriques
        2021-07-28 16:11:24.651Z2021-07-29 00:40:01.086Z

        Hello @alex_alcanjim,

        Try this and let me know how it goes.

        function clearMemoryLocations(name) {
        
            const isMemLocWinOpened = sf.ui.proTools.getMenuItem('Window', 'Memory Locations').isMenuChecked
        
            // //  Open mem loc win
            sf.ui.proTools.memoryLocationsShowWindow()
        
            // Get Memory Locations including...
            const memoryLocations = sf.proTools.memoryLocationsFetch().collection['List'].filter(m => m.name.includes(name))
        
            // Clear found
            memoryLocations.forEach(memLoc => {
                sf.ui.proTools.memoryLocationsGoto({ memoryLocationNumber: memLoc.number })
                sf.ui.proTools.memoryLocationsWindow.popupButtons.first.popupMenuSelect({ menuPath: ['Clear*'], useWildcards: true });
            });
        
            alert(`Cleared All Memory Locations Names Including: \n\n                       - ${name} -`)
        
        
            // Set initial state of Mem Loc Win
            if (!isMemLocWinOpened) {
                sf.ui.proTools.menuClick({ menuPath: ['Window', 'Memory Locations'], targetValue: "Disable" })
            };
        };
        
        
        
        clearMemoryLocations('Location')
        
        
        Reply3 LikesSolution
        1. samuel henriques @samuel_henriques
            2021-07-28 20:36:05.230Z

            Just updated a much simpler version.

            1. Aalex alcanjim @alex_alcanjim
                2021-07-30 14:24:25.179Z

                Hi @samuel_henriques !

                Thanks so much! It works perfect!

              • Here's a verison that allows you to search your memory locations instead of a fixed text. Prompt tech also written by @samuel_henriques

                function clearMemoryLocations(name) {
                
                    // Get Memory Locations including...
                    const memoryLocations = sf.proTools.memoryLocationsFetch().collection['List'].filter(m => m.name.includes(name))
                
                    // Clear found
                    memoryLocations.forEach(memLoc => {
                        sf.ui.proTools.memoryLocationsGoto({ memoryLocationNumber: memLoc.number })
                        sf.ui.proTools.memoryLocationsWindow.popupButtons.first.popupMenuSelect({ menuPath: ['Clear*'], useWildcards: true });
                    });
                
                };
                
                function prompt(item) {
                    let prompt = sf.interaction.popupSearch({
                        items: item.map(x => ({ name: x["Name"] }))
                    }).item.name
                    return prompt
                };
                
                function main() {
                
                    const isMemLocWinOpened = sf.ui.proTools.getMenuItem('Window', 'Memory Locations').isMenuChecked
                
                    // //  Open mem loc win
                    sf.ui.proTools.memoryLocationsShowWindow()
                
                    let memoryLocations = sf.proTools.memoryLocationsFetch().collection['List']
                    let promptValue = prompt(memoryLocations)
                
                    clearMemoryLocations(promptValue)
                
                    // Set initial state of Mem Loc Win
                    if (!isMemLocWinOpened) {
                        sf.ui.proTools.menuClick({ menuPath: ['Window', 'Memory Locations'], targetValue: "Disable" })
                    };
                }
                
                main()