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 find Scripting Examples?

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



Joined: 29 Jul 2005
Posts: 6

PostPosted: Fri Jul 29, 2005 2:22 pm    Post subject: How to find Scripting Examples? Reply with quote

I have reviewed the API documentation both at Sony and "ayizwe.net" however; there do not appear to be any examples on how to write the code.

For example:

abstract class Track
Inherits from: System.Object
String Name = Get or set the name of the track

That gives me the information on what property I should use to get or set the track name, however; I have no idea on what syntax to use to actually get or set the name.

Are there any sites/books that give explicit examples on what needs to be done?

Thank you for your time.
Back to top
View user's profile Send private message
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Fri Jul 29, 2005 2:54 pm    Post subject: Reply with quote

There's quite a bit of information in the various newsletters. Plus, a great learning tool is looking at other scripts that are available for free download. Tear the script apart to see what makes it work! A third resource would be to simply ask questions.

BTW, to set a track's name

for (var currentTrack : Track in Vegas.Project.Tracks)
{
currentTrack.Name = "Whatever you want to name it";
}
Back to top
View user's profile Send private message Send e-mail
avd



Joined: 29 Jul 2005
Posts: 6

PostPosted: Fri Jul 29, 2005 3:24 pm    Post subject: Reply with quote

Thank you for your quick reply.

I have been working through multiple scripts from various locations to help learn the code better, however; I was hoping there was something similar to any of the standard help files in VB or VBA, C++, etc. For example:

In the help file it will provide the syntax and then give a code example on how that syntax is used. Thereby providing a basis to start from.

In addition, the code I figured out was similar but kept returning an error:

import Sony.Vegas;
import System.Object;

for (var track in Vegas.Project.Tracks)
{
Track.Name = "MyName";
}


That code received the response of:

Compilation error on line 6:

'Track.Name' is read-only

System.ApplicationException: Failed to compile script: 'C:\Programs\Video\Vegas6\Script Menu\NameTracksInSequence.js'
at Sony.Vegas.VSAManager.Compile()
at Sony.Vegas.ScriptHost.RunScript(Boolean fCompileOnly)

---------------------------
Which, after taking a second look, realized it was a "CaSe" error. With, I am assuming, "Track" being the reserved word/class.

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


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Fri Jul 29, 2005 3:28 pm    Post subject: Reply with quote

Upper/Lower case makes a difference. In this case:

Track.Name = "MyName";

should have been:

track.Name = "MyName";

because your variable's name is "track".
Back to top
View user's profile Send private message Send e-mail
avd



Joined: 29 Jul 2005
Posts: 6

PostPosted: Fri Jul 29, 2005 3:52 pm    Post subject: Reply with quote

Thank you.

If I may continue to ask....

Expanding on the previous snippet of code, I have created the following:

-----------------------------------
import System.Windows.Forms;
import System.Object;
import Sony.Vegas;

var currenttrack = Sony.Vegas.Track;
var currentname = 1;
var trackEnum = new Enumerator(Vegas.Project.Tracks);

try
{
while(!trackEnum.atEnd())
{
MessageBox.Show(currenttrack.Name);
if(currenttrack.IsVideo)
{
MessageBox.Show("IsVideo");
currenttrack.Name = currentname;
}
if(currenttrack.IsAudio)
{currenttrack.Name = currentname; currentname++;}
trackEnum.moveNext();
}
}
catch (e)
{
MessageBox.Show(e);
}
-----------------------------------
Unfortunately, for the first message box I only receive:

"Track"

(there are currently four tracks - no events)

Nor do I receive any response from the second message box re: Is Video.

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


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Fri Jul 29, 2005 4:37 pm    Post subject: Reply with quote

Try this instead:


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

var currentname = 1;

try
{
  var trackEnum = new Enumerator(Vegas.Project.Tracks);
  while (!trackEnum.atEnd())
  {
    var currenttrack : Track = Track(trackEnum.item());
    MessageBox.Show(currenttrack.Name);

    if (currenttrack.MediaType == MediaType.Video)
    {
      MessageBox.Show("IsVideo");
      currenttrack.Name = currentname;
    }

    if (currenttrack.MediaType == MediaType.Audio)
    {
      MessageBox.Show("IsAudio");
      currenttrack.Name = currentname;
      currentname++;
    }

    trackEnum.moveNext();
  }
}
catch (e)
{
  MessageBox.Show(e);
}
Back to top
View user's profile Send private message Send e-mail
avd



Joined: 29 Jul 2005
Posts: 6

PostPosted: Fri Jul 29, 2005 5:09 pm    Post subject: Reply with quote

Thank you, that worked well.
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 -> 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