"working" tracks

jetdv wrote on 6/25/2003, 3:02 PM
When using tracks/track variables, Normally I add a track similar to:

Mtrack = new VideoTrack(1, "My Track");
Vegas.Project.Tracks.Add(Mtrack);


Now, what if I only do the first line? Can I still add events to it and operate on them normally? If I never do the second line, will that track then simply disappear when the script ends?

I other words:

Mtrack = new VideoTrack(1, "My Track");
// Process Mtrack by moving stuff to it, splitting, copying, whatever...
// end of script

The track will just go away as if it never existed since it was never "added"? Or should it be added and then deleted?

Comments

roger_74 wrote on 6/26/2003, 9:24 AM
In a normal dotnet application objects that are no longer referenced are destroyed by the garbage collector. How it works in a VSA application I'm not sure, since I think it's up to the host application.

It's not an answer but it's something :-)
jetdv wrote on 6/26/2003, 11:21 AM
Thanks, roger,

Further testing seems to bear this out. HOWEVER, it seems I cannot add events to that track. Is it true that events cannot be added to a track variable if that track has not been added to the project?
SonyPJM wrote on 6/30/2003, 9:24 AM
Until you add them to an appropriate container newly constructed objects are invalid. You cannot do anything to a track object, including adding events to it, until after the track has been added to the project's track list. One special case is Media objects, which are added to the media pool when they are constructed.
jetdv wrote on 6/30/2003, 10:03 AM
Thanks, that's what I ended up doing. Create track, add track, use track, delete track.