Comments

jetdv wrote on 10/11/2023, 8:56 PM

What do you mean by "maintain aspect ratio"? If you mean the standard right-click Pan/Crop and "Match Output Aspect", just get any of the scripts that will work in 14+ and change "Using ScriptPortal.Vegas;" to "Using Sony.Vegas;" and it will work fine.

 

Camby112 wrote on 10/12/2023, 7:32 AM

like when you right click on a video clip and switches then maintain aspect ratio.

jetdv wrote on 10/12/2023, 7:56 AM
            VideoEvent vEvent = (VideoEvent)myVegas.Project.Tracks[0].Events[0];
            bool vAspect = vEvent.MaintainAspectRatio;
            vEvent.MaintainAspectRatio = true;

Just get the "VideoEvent" for the event in question and change the .MaintainAspectRatio property. The code above would show how you read and change that property on the first event on the first track. Here's the code expanded to show how it can work with "all selected events".
 

using Sony.Vegas;  //ScriptPortal.Vegas for VP14 and newer

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

        public void Main(Vegas vegas)
        {
            myVegas = vegas;

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                foreach(TrackEvent evnt in myTrack.Events)
                {
                    if (evnt.Selected && evnt.IsVideo())
                    {
                        VideoEvent vEvent = (VideoEvent)evnt;
                        vEvent.MaintainAspectRatio = true;
                    }
                }
            }
        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

 

Camby112 wrote on 10/12/2023, 7:48 PM

thanks! i really appreciate your help!