No internet connection
  1. Home
  2. How to

Safety Net: if NO clips selected -> Abort/throw Error

By Ingo Pusswald @ingo_luftrausch
    2020-11-23 09:22:38.298Z

    Hi,
    I need a SafetyNet that checks if any Clips are selected, if no clips selected abort/throw error.

    All I tried faild :-(

    Thanks for help!

    Solved in post #6, click to view
    • 9 replies
    1. Kitch Membery @Kitch2020-11-23 11:02:47.248Z2020-11-23 11:11:32.747Z

      Hi @ingo_luftrausch,

      Did you try the script in this post by chance?

      1. Ingo Pusswald @ingo_luftrausch
          2020-11-23 11:04:57.243Z

          Hi Kitch,
          which post? (no link)

          1. In reply toKitch:
            Ingo Pusswald @ingo_luftrausch
              2020-11-23 11:08:03.449Z2020-11-23 11:15:04.990Z

              I´m currently trying this one:

              sf.ui.proTools.appActivateMainWindow();
              
              const audioExists = sf.ui.proTools.getMenuItem('Clip', 'Edit Lock/Unlock').isEnabled;
              
              if(audioExists){
                  log('Audio Exists in the selection!')
              } else {
                  log('Audio does not Exist in the selection')
              }
              

              But my scripting skills are very bad :-(

              1. In reply toKitch:
                Ingo Pusswald @ingo_luftrausch
                  2020-11-23 11:15:56.452Z

                  Yeah, that's the one.
                  But I'm unable to change behaviour if audio exist = continue, No audio = abort/throw error

                  1. Kitch Membery @Kitch2020-11-23 11:20:29.868Z

                    Got it!

                    This should do the trick;

                    const audioExists = sf.ui.proTools.getMenuItem('Edit', 'Trim Clip', 'To Selection').isEnabled;
                    
                    if(!audioExists) throw `No audio exists`;
                    
                    //Add rest of script here.
                    
                    

                    Rock on!

                    ReplySolution
                    1. Ingo Pusswald @ingo_luftrausch
                        2020-11-23 11:39:41.878Z

                        Okok, superduper!

                        so far so good, THANKS!

                        I changed getMenuItem to "Clip, Edit Lock/Unlock" cause its active only when at least one full clip is selected.

                        Throw Error message is a bit confusing " Error running .... ck0i8..... line 5 .... NoAudioExsist".
                        Is it possible to reduce the message to only show "No Audio..."?

                        thanks in advance!

                        1. Kitch Membery @Kitch2020-11-23 11:54:19.939Z

                          Awesome.

                          Regarding the error message, Will have to look into that one for you mate.

                          1. In reply toingo_luftrausch:
                            Dustin Harris @Dustin_Harris
                              2020-11-27 04:43:32.923Z

                              Try:

                              const audioExists = sf.ui.proTools.getMenuItem('Edit', 'Trim Clip', 'To Selection').isEnabled;
                              
                              if(!audioExists) {
                              log(‘No Audio Selected’);
                              throw 0;
                              }
                              //Add rest of script here.
                              

                              :)

                              1. Kitch Membery @Kitch2020-11-27 05:29:15.867Z

                                It must have been late hahahaa thanks Dustin.