www.jetdv.com Forum Index Edward Troxel
Vegas Scripting and Newsletters
Home of Excalibur and Montage Magic
 
 FAQ   Search   Memberlist   Usergroups   Register   Profile 
 Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to tell a script to only do selected tracks

 
Post new topic   Reply to topic    www.jetdv.com Forum Index -> Scripting FAQ
View previous topic :: View next topic  
Author Message
cooldraft



Joined: 09 Dec 2004
Posts: 249
Location: Oklahoma City

PostPosted: Mon Mar 27, 2006 2:48 pm    Post subject: How to tell a script to only do selected tracks Reply with quote

I want to modify the select small events (if that is ok) to only work on the tracks that I have selected, in lieu of each track in succession as it it written. I know the key lies in the while statement, but don't know the parameter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Mon Mar 27, 2006 4:20 pm    Post subject: Reply with quote

Just do the inner routine ONLY if the track is selected. Something like this:

Code:
if (track.Selected)
{
    //Go through the list of Events
    var eventEnum = new Enumerator(track.Events);
    while (!eventEnum.atEnd()) {
      var evnt : TrackEvent = TrackEvent(eventEnum.item());

      if (evnt.Length <= maxsize)
      {
         evnt.Selected = true;
      } else {
         evnt.Selected = false;
      }
      eventEnum.moveNext();
    }
}
Back to top
View user's profile Send private message Send e-mail
cooldraft



Joined: 09 Dec 2004
Posts: 249
Location: Oklahoma City

PostPosted: Tue Mar 28, 2006 2:18 am    Post subject: Poor me. Sorry. I p;ayed wit this for nearly an hour. Reply with quote

try {
var maxsize : Timecode = new Timecode("00:00:02:00");

if (track.Selected)
{
//Go through the list of Events
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
var evnt : TrackEvent = TrackEvent(eventEnum.item());

if (evnt.Length <= maxsize)
{
evnt.Selected = true;
} else {
evnt.Selected = false;
}
eventEnum.moveNext();
}

}
} catch (e) {
MessageBox.Show(e);
}



Compilation error on line 19:

Variable 'track' has not been declared
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Tue Mar 28, 2006 2:55 am    Post subject: Reply with quote

That's because you didn't include the rest of the script. I only listed the middle part. You left out the "track" while loop. Here's the whole thing:

Code:
/**
 * This script will select all events whose length is
 * less than or equal to "maxsize" for all selected tracks
 *
 * Written By: Edward Troxel
 * Copyright 2006 - JETDV Scripts
 * Modified: 03-27-2006
 **/

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;


try {
  var maxsize : Timecode = new Timecode("00:00:01:00");

  //Go through the list of Tracks
  var trackEnum = new Enumerator(Vegas.Project.Tracks);
  while (!trackEnum.atEnd()) {
    var track : Track = Track(trackEnum.item());

    if (track.Selected)
    {
      //Go through the list of Events
      var eventEnum = new Enumerator(track.Events);
      while (!eventEnum.atEnd()) {
        var evnt : TrackEvent = TrackEvent(eventEnum.item());

        if (evnt.Length <= maxsize)
        {
           evnt.Selected = true;
        } else {
           evnt.Selected = false;
        }
        eventEnum.moveNext();
      }
    }
    trackEnum.moveNext();
  }


} catch (e) {
    MessageBox.Show(e);
}
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    www.jetdv.com Forum Index -> Scripting FAQ All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.11 © 2001, 2002 phpBB Group