Tracks.Clear() - Exception

ingvarai wrote on 1/26/2009, 3:06 PM
Hi,
I am new to scripting in Vegas, but not new to programming.
When I program anything trying to alter a track in Vegas, I get exceptions. Like this:

MyVegas.Project.Tracks.Clear();
An Exception is thrown. Likewise with this:

MyVegas.Project.Tracks[0].Selected = true;
or
MyVegas.Project.Tracks[0].Solo = true;

Obviously I am missing something, but what?
The project has several tracks on the tim eline when I do this, Track[0] is a video track

ingvarai

Comments

jetdv wrote on 1/26/2009, 5:39 PM
I usually do something like:

foreach (Track track in Vegas.Project.Tracks)
{
if (track.Selected)
{...

And these work fine for me:

Vegas.Project.Tracks.Add(newtrack);
Vegas.Project.Tracks.Remove(svTrack);


But I see no reason why you cannot access a specific track. These also work for me:

lblLength.Text = "Length: " + myVegas.Project.Tracks[2].Length;

Track myTrack = myVegas.Project.Tracks[2];

myVegas.Project.Tracks[2].Mute = true;



Now... if you're writing a Custom Command, remember that anything that CHANGES the project must be in an "Undo" block or you WILL get an error.



ingvarai wrote on 1/26/2009, 11:46 PM
Now... if you're writing a Custom Command, remember that anything that CHANGES the project must be in an "Undo" block or you WILL get an error.

Thanks a lot! This has to be the culprit. I will try it later today, and report back.

Edited:
I found this: http://forums.creativecow.net/thread/24/880218

ingvarai