Newbie: How to add Track

ponchoman1 wrote on 7/30/2004, 5:35 PM
I'm brand new to JBscript and Vegas scripting. I need help getting started. With a blank project opened, how do I add a track using VBscript? Then, how do I add a footage file to the track from my harddrive?

Also, is it possible to access the Track Motion properties of a track through scripting? I want to create different tracks in one project that have different scale settings.


I know this is pretty basic but I've been looking at the API and it doesn't make sense to me.

Thanks for any help.
Mike

Comments

jetdv wrote on 7/30/2004, 6:51 PM
Take a look here for a quick start guide.
ponchoman1 wrote on 7/30/2004, 7:40 PM
I've been to the scripting FAQs page. It looks like it has a lot of vaulable info for a beginner like me, however, I could not find any info there about adding a Track to a project using a script. It has info about adding events and finding tracks but not about adding tracks.

Any help would be great.
Thx, Mike
jetdv wrote on 7/30/2004, 8:06 PM
var Mtrack = new VideoTrack(0, "TrackName");
Vegas.Project.Tracks.Add(Mtrack);
ponchoman1 wrote on 7/30/2004, 11:19 PM
Hi jetdv,
When I run the following script, I get this error message....

"Reference to a non-shared member requires an object reference"
From what I can tell from some research, this has to do with the .net framework. However, I do not know how to make the required object reference. I've tried nurmerous things with no success. Any hlep would be appreciated.


' VBScript source code

OPTION STRICT OFF
OPTION EXPLICIT OFF

imports System
imports System.Windows.Forms
imports SonicFoundry.Vegas


Public Module MainModule
Public Sub Main()

Mtrack = new VideoTrack(0,"NewTrack")
Vegas.Project.Tracks.Add(Mtrack)


End Sub
End Module
jetdv wrote on 7/31/2004, 4:35 AM
The code I gave you was for JScript - NOT VBScript. You'll find many more samples in JScript.

Try something like this for VBScript:

Dim Mtrack As New VideoTrack(0,"NewTrack")
VegasApp.Project.Tracks.Add(Mtrack)


Plus, are you using Vegas 4 or Vegas 5? If you're using Vegas 5, the "import" line should be "Sony.Vegas".
ponchoman1 wrote on 7/31/2004, 2:44 PM
Thanks for the help. The script worked. I do have a question about the following line...

VegasApp.Project.Tracks.Add(Mtrack)

Is "VegasApp" specific to vbscript? I would never had thought of trying this. I've been using Vegas.Project.Tracks.Add() with no success. If there are differences with the objects' names between jscript and vbscript, are they documented anywhere? I didn't find anything in the API document.

Is there a reason why 99.9% of the vegas scripts are written in jscript?

Thx for your help.
JohnnyRoy wrote on 8/1/2004, 9:43 AM
> Is there a reason why 99.9% of the vegas scripts are written in jscript?

I would guess that the reason is that JScript.net is close enough to JavaScript, or C#, or Java, or C++, that anyone who knows any of those programming languages could pick it up quickly. VBScript.net, however, is a rather unique language known only to VisualBasic programmers.

If I were you, I would write your scripts in JScript and go to the Sundance Media Group site and download some of the scripts that are there. You will find one that probably has pieces of most of what you would want to do. For example, my TrackSetUp script would have shown you how to add tracks.

It’s you’re choice but if you’re going to use VBScript, you’re going to have to do a lot of translating from JScript to VBScript on your own.

~jr