Is there any script to select the oddth track events in track?

webcam wrote on 7/25/2020, 2:18 AM

I just want to make a script like the image that I posted, but I don't know there is a way to select oddth track events.

Is there any class or method to do that?

I'm trying to manipulate the script that select events after cursor from this link, https://www.vegascreativesoftware.info/us/forum/select-all-events-after-cursor--118989/

but I'm not familiar with C#, so manipulating is too difficult for me.

Comments

jetdv wrote on 7/25/2020, 10:21 AM

Well... that is certainly doable via a script. Do you always want it to skip the first one, select the second one, skip the third one, select the 4th one? Or should it do every-other one after the first selected?

jetdv wrote on 7/25/2020, 10:26 AM

Something like this should do it:

                foreach (Track myTrack in ScriptPortal.Vegas.Tracks)
                {
                    if (myTrack.Selected)
                    {
                        bool selectThisOne = false;
                        foreach(TrackEvent myEvent in myTrack.Events)
                        {
                            myEvent.Selected = selectThisOne;
                            selectThisOne = !selectThisOne;
                        }
                    }
                }

 

webcam wrote on 7/26/2020, 9:51 AM

Something like this should do it:

                foreach (Track myTrack in ScriptPortal.Vegas.Tracks)
                {
                    if (myTrack.Selected)
                    {
                        bool selectThisOne = false;
                        foreach(TrackEvent myEvent in myTrack.Events)
                        {
                            myEvent.Selected = selectThisOne;
                            selectThisOne = !selectThisOne;
                        }
                    }
                }

 

Thanks! After tweaking a little bit, I achieved what I want. (I changed the code to allow you to select a file in the multiple of n.) But it selects like first picture(red squares mean selected files) when the file is located in the middle of the track bar, not like the second picture(what I intended) Do you know what is the problem of my code?

Here is my code. (in this case, the number of nthObject is key number)

using System;
using ScriptPortal.Vegas;
public class EntryPoint
{  
    public void FromVegas(Vegas myVegas)
    {
        foreach (Track myTrack in myVegas.Project.Tracks)
        {
            if (myTrack.Selected)
            {
                int objectNum = 0;
                int nthObject = 2; //If you want to change the Nth object to select, change this number to N which you want.
                foreach(TrackEvent myEvent in myTrack.Events)
                {
                    if (myEvent.Start >= myVegas.SelectionStart && myEvent.Start <= (myVegas.SelectionStart + myVegas.SelectionLength))
                    {
                        if (objectNum % nthObject == 0)
                        {
                        myEvent.Selected = true;
                        objectNum++;
                        }
                        else
                        {
                        myEvent.Selected = false;
                        objectNum++;
                        }
                    }
                }
            }
        }
    }
}