Hi everyone!
While these forums have been a great source for helping me troubleshoot VEGAS Pro in the past, I've been browsing a lot more recently. I've been tinkering with its native features and there are a few that I never thought I'd have a use for that are now crucial to my workflow, so I've been coming back here to see if there were any resources here that would help further.
One thing that I realized was helping a lot were Scripts, and have seen a lot of users share theirs here, so I wanted to contribute as well. I wanted to share it on its own post so it could be easily found.
I work with Groups a lot, since I usually deal with hundreds of Events on my Timeline on any given Project. Selecting each block of Events and Grouping them (literally hundreds of times depending on the Project) does get old after a while. I wondered if there was a way to just Group the Events on one Track with whatever was on the Track above or below it, but I wasn't finding anything online, nor on any of the available Extensions others have created.
After a while of reading through some of the posts here, I came to realize that maybe this could be done through Grouping whatever was on any given Track, contained within a Region. While I'm no programmer, I did my best to interpret the code I found in tutorials from users here, as well as doing my best to guess if I was using the API's definitions and structures correctly.
After a lot of trying to figure out why it wasn't working, I eventually landed on this, which I hope will help someone else the way you guys have helped me!
using System;
using System.Collections.Generic;
using ScriptPortal.Vegas;public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
// Go through each Region in the active Project's Timeline
foreach (Region region in vegas.Project.Regions)
{
// Create a Group at each Region
TrackEventGroup grp = new TrackEventGroup();
vegas.Project.Groups.Add(grp);
// List to hold the Events within each Region's time range
List<TrackEvent> eventsToGroup = new List<TrackEvent>();
// Apply to all Tracks in the active Project
foreach (Track myTrack in vegas.Project.Tracks)
{
// Apply to all Events in any given Track
foreach (TrackEvent evt in myTrack.Events)
{
// Check if the Events are within the Region's Start Position and End time
if (evt.Start >= region.Position && evt.End <= region.End)
{
// Add the Event to the list of Events to be Grouped
eventsToGroup.Add(evt);
}
}
} // Add all Events that are within the Region to the Group
foreach (TrackEvent eventToGroup in eventsToGroup)
{
grp.Add(eventToGroup);
}
}
}
}
Please let me know if you find this useful at all! Also, if the code can be simplified or if I did something completely unnecessary here, please let me know. I'm still learning how to interpret and write these, so I don't always know what can and can't be done.