Select event under cursor of current track

stefan-m2020 wrote on 7/8/2020, 2:13 PM

Hello!

Software: Magix Vegas Pro 17, Windows 10 64 Bit Pro

I'm new and must admit that I have very little knowledge of programming (especially .cs).

I found an interesting script which selects ALL events of ALL tracks under the cursor position,

using System;
using System.Windows.Forms;
using ScriptPortal.Vegas;namespace ClassLibrary3
{    public class EntryPoint
    {        
        public void FromVegas(Vegas vegas)
        {            try
            {
                DeselectAll(vegas);                // step through all the tracks
                foreach (var track in vegas.Project.Tracks)
                {
                    // Step through all events
                    foreach (var evnt in track.Events)
                    {
                        // Check to see if event is under or to the right of the cursor
                        //if (-1 == vegas.Cursor.CompareTo(evnt.Start + evnt.Length))
                        if (evnt.Start <= vegas.Transport.CursorPosition && evnt.End >= vegas.Transport.CursorPosition)
                        {
                            evnt.Selected = true;
                        }
                        else
                        {
                            evnt.Selected = false;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }        }        public void DeselectAll(Vegas vegas)
        {// step through all the tracks
            foreach (var track in vegas.Project.Tracks)
            {
                // Step through all events
                foreach (var evnt in track.Events)
                {
                    evnt.Selected = false;
                }
            }
            return;
        }    }
}

I would like to modify the script, so that it only selects 1 event of the currently highlighted track.

After several trials and errors I finally gave up!

Can you assistent, please?

Thanks for any help and best regards!

Comments

wwaag wrote on 7/8/2020, 4:04 PM

Sure. Just add the following line:

if(!track.Selected) continue

between your lines:

{

// Step through all events.

In this way, only events on Selected tracks will be selected.

You can download a number of select event scripts (before, under, after cursor, with markers) in the HappyOtter Free Tools Library at https://tools4vegas.com/library/

Just looked, and in fact, the script you have is from that library.

AKA the HappyOtter at https://tools4vegas.com/. System 1: Intel i7-8700k with HD 630 graphics plus an Nvidia RTX4070 graphics card. System 2: Intel i7-3770k with HD 4000 graphics plus an AMD RX550 graphics card. System 3: Laptop. Dell Inspiron Plus 16. Intel i7-11800H, Intel Graphics. Current cameras include Panasonic FZ2500, GoPro Hero11 and Hero8 Black plus a myriad of smartPhone, pocket cameras, video cameras and film cameras going back to the original Nikon S.