[Absolute beginner] Unexpected and inconsistent behaviour in my script

SUPERNOOB20 wrote on 12/28/2025, 1:31 PM

Hi! I have been trying to get into Vegas Scripting, but my scripts either don't compile; throw various nonsense errors; or sometimes do compile, but show nonsensical behaviour

 

Consider for example the following code (Which I stored in "C:\Program Files\VEGAS\VEGAS Pro 17.0\Script Menu\hello_fruits_vegas.cs")

using System.Windows.Forms;

using ScriptPortal.Vegas;


public class EntryPoint

{

    public void FromVegas(Vegas vegas)

    {


        string[] fruits;

        fruits = new string[] {"banana", "apple", "tomato", "cat (just kidding)"};

       

        foreach (Track myTrack in vegas.Project.Tracks)

        {

            foreach (TrackEvent event in myTrack.TrackEvents)

            {

                if (event.Selected)

                {

                    MessageBox.Show(fruits[1]);

                }

            }

        }

    }

}

 

This code will either show message boxes of all the fruits in fruits (unexpected behaviour) or not compile at all and show an error similar to this one (taking from a slightly different script because I failed to reproduce):

This is the code for that one, if you were wondering:

using System;

using System.Drawing;

using System.Collections;

using System.Windows.Forms;

using ScriptPortal.Vegas;



public class EntryPoint

{

    public void FromVegas(Vegas vegas)

    {

       

        foreach (Track myTrack in vegas.Project.Tracks)

        {

            foreach (VideoEvent event in myTrack.Events)

            {

                if (event.Selected)

                {

                    event.MaintainAspectRatio = false;       // videoEvent.MaintainAspectRatio;

                }

            }

        }

               


        MessageBox.Show("Meow :3");

    }

}

 

As you can see, the code is totally fine and it should compile just fine... what on Earth is going on? "^^

 

~ SUPERNOOB

 

Comments

SUPERNOOB20 wrote on 12/28/2025, 2:03 PM

** Update on the second code snippet:


 

using System;

using System.Drawing;

using System.Collections;

using System.Windows.Forms;

using ScriptPortal.Vegas;



public class EntryPoint

{

    public void FromVegas(Vegas vegas)

    {

       

        foreach (Track myTrack in vegas.Project.Tracks)

        {

            foreach (TrackEvent event in myTrack.Events)

            {

                if (event.Selected) && (event.MediaType.Video)

                {

                    event.MaintainAspectRatio = false;       // videoEvent.MaintainAspectRatio;

                }

            }

        }

               


        MessageBox.Show("Meow :3");

    }

}

(It still doesn't work anyway)