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 

Vol #1, Issue #1 (March 2003)

 
Post new topic   Reply to topic    www.jetdv.com Forum Index -> Newsletter Archive
View previous topic :: View next topic  
Author Message
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5103

PostPosted: Tue Aug 03, 2004 6:38 pm    Post subject: Vol #1, Issue #1 (March 2003) Reply with quote

The premiere issue of Vegas Tips, Tricks, and Scripts.

In this issue:

What is Tips, Tricks, and Scripts
Vegas Preferences - Part 1
What is Scripting
Fade the Selected Event In and Out

Download Vol. 1, Issue 1


Last edited by Edward Troxel on Sun Mar 15, 2009 12:51 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
dturnidge



Joined: 11 Feb 2006
Posts: 2

PostPosted: Sun Feb 12, 2006 12:59 am    Post subject: Reply with quote

I downloaded and printed all your newsletters and started reading. I typed in your fadeinfadeout javascript, and had the following error:

Compilation error on line 25:

Variable 'TrackEvent' has not been declared


System.ApplicationException: Failed to compile script: 'C:\Program Files\Sony\Vegas 6.0\Script Menu\FadeInFadeOut.js'
at Sony.Vegas.VSAManager.Compile()
at Sony.Vegas.ScriptHost.RunScript(Boolean fCompileOnly)


This is what I entered:

/**
* This script will add a one second fade in and fade out on the selected event
* Written by: Edward Troxel
* Revised: 02/26/2003
**/

import System.Windows.Forms;
import SonicFoundry.Vegas;

try {

// Find the selected event
var evnt = FindSelectedEvent();
if (null == evnt)
throw "no selected event";

// Now set the one second fade in and fade out
evnt.FadeIn.Length = new Timecode(1000);
evnt.FadeOut.Length = new Timecode(1000);

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

function FindSelectedEvent() : TrackEvent {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
var evnt : TrackEvent = TrackEvent(eventEnum.item());
if (evnt.Selected) {
return evnt;
}
eventEnum.moveNext();
}
trackEnum.moveNext();
}
return null;
}


I have worked very sparingly with JS, so it is very likely that I entered something wrong. Please let me know what you see...

Thanks,

Dave
Back to top
View user's profile Send private message
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5103

PostPosted: Sun Feb 12, 2006 1:28 am    Post subject: Reply with quote

That's an easy one. That article was written on Vegas 4. Sony purchased Vegas while Vegas 4 was current and the following change is required for Vegas 5 or Vegas 6. Try making this change:

Find:
import SonicFoundry.Vegas;

and change it to:
import Sony.Vegas;


After making the above change, all should work as expected.
Back to top
View user's profile Send private message Send e-mail
dturnidge



Joined: 11 Feb 2006
Posts: 2

PostPosted: Sun Feb 12, 2006 1:54 am    Post subject: Reply with quote

Cool! It worked! Hopefully, before I get done with your "book" I'll be able to write the one I need!!

Dave
Back to top
View user's profile Send private message
Rekcin



Joined: 04 Dec 2006
Posts: 3
Location: Nashville, TN

PostPosted: Tue Dec 05, 2006 3:35 pm    Post subject: Changes Reply with quote

Is there an easy way to make this work on all selected events?
_________________
Doh!
Back to top
View user's profile Send private message
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5103

PostPosted: Tue Dec 05, 2006 6:22 pm    Post subject: Reply with quote

Yes there is. The Fade tool in Excalibur does this.

Here's an untested quickie:

Code:
import System.Windows.Forms;
import Sony.Vegas;

try {
  var trackEnum = new Enumerator(Vegas.Project.Tracks);
  while (!trackEnum.atEnd()) {
    var track : Track = Track(trackEnum.item());
    var eventEnum = new Enumerator(track.Events);
    while (!eventEnum.atEnd()) {
      var evnt : TrackEvent = TrackEvent(eventEnum.item());
      if (evnt.Selected) {
        // Now set the one second fade in and fade out
        evnt.FadeIn.Length = new Timecode(1000);
        evnt.FadeOut.Length = new Timecode(1000);
      }
      eventEnum.moveNext();
    }
    trackEnum.moveNext();
  }
} catch (e) {
MessageBox.Show(e);
}
 
Back to top
View user's profile Send private message Send e-mail
Rekcin



Joined: 04 Dec 2006
Posts: 3
Location: Nashville, TN

PostPosted: Tue Dec 05, 2006 6:50 pm    Post subject: Awesome! Reply with quote

Your untested quickie works like a charm, and saved me hours of manual work. Thank you so much. Very Happy
_________________
Doh!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    www.jetdv.com Forum Index -> Newsletter Archive 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