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.
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);
}
}