Comments

jetdv wrote on 6/19/2004, 4:10 AM
That cannot currently be done. while you can read the text file and create the generated media, the script cannot change the text in the generated media.
Texte wrote on 6/19/2004, 1:01 PM
Hi Jetdv

Not to change txt to media .
but cop line by line frome txt and paste to sony textmedia.
manualy I can do this .
I explain manualy:
Open végas v5 ,add video track, then
Open the txt fil ,select a line, and copy , come to végas v5 ,add texmedia to trac (the default is sample texte ) so paste and change the size and property to the texte. that's all
Ine to do this by scripting végas v5.
I don't know to script this.
jetdv wrote on 6/19/2004, 10:21 PM
I'll repeat, you cannot change the text in the text generated media from a script. That is the only step you CANNOT do - changing the text in the generated media.
Texte wrote on 6/20/2004, 12:42 AM
Jetdv I'm sorry I'm not a good programmer ,can you help me to make this scpipt run in végas v5 I'v find it in FAQ that you've give me. It can put HOT lake preset.
Just for an exemple please


var track = FindSelectedTrack();
if (null == track)
throw "no selected track";
if (!track.IsVideo())
throw "no selected track not video";
var cursorTimecode = Vegas.Cursor;
var media = CreateGeneratedMedia("Sony Text", "Hot");
var stream = media.Streams[0];
var newEvent = new VideoEvent(cursorTimecode, stream.Length);
track.Events.Add(newEvent);
var take = new Take(stream);
newEvent.Takes.Add(take);



Thanks
jetdv wrote on 6/20/2004, 4:48 AM
You need to add the import statement(s) at the top and you need to add the "FindSelectedTrack" routine. There are more import statements here than you need but they are the standard ones I add.


import System;
import System.Collections;
import System.Text;
import System.IO;
import System.Drawing;
import System.Windows.Forms;
import Sony.Vegas;



try {

var track = FindSelectedTrack();
if (null == track)
throw "no selected track";
if (!track.IsVideo())
throw "no selected track not video";
var cursorTimecode = Vegas.Cursor;
var media = CreateGeneratedMedia("Sony Text", "Hot");
var stream = media.Streams[0];
var newEvent = new VideoEvent(cursorTimecode, stream.Length);
track.Events.Add(newEvent);
var take = new Take(stream);
newEvent.Takes.Add(take);


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

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


Texte wrote on 6/20/2004, 5:17 AM
Thank you very much Jetdv
It work
each time I run this script the textmedia ""HOT"" is apear on the track but I have to move the cursor to the end of this media to run again this script.
what script to write on to get the cursor automatiquely at the end of the media ? I search on the web to learning the végas script but it's so dificulte to understand the végas script. I only have a basic programmation.
You are the first one who guive me the script that I need.
I think I'm lucky.
Please Help me again...
Thanks again
jetdv wrote on 6/20/2004, 11:10 AM
Try adding:

Vegas.Cursor = track.Length;

after:

newEvent.Takes.Add(take);
Texte wrote on 6/20/2004, 12:50 PM
Thanks again It work
I just click on the script and it done .

I need to make a boucle : some think like this: in basic "for i = 1
do loop ........until i =15.
so when I click one time then the script put 15 HOT to the track.
and then I come to change manualy the preset that the script can't do for me.
thanks
jetdv wrote on 6/20/2004, 1:12 PM

import System;
import System.Collections;
import System.Text;
import System.IO;
import System.Drawing;
import System.Windows.Forms;
import Sony.Vegas;
try {
var i;
var track = FindSelectedTrack();
if (null == track)
throw "no selected track";
if (!track.IsVideo())
throw "no selected track not video";
var cursorTimecode = Vegas.Cursor;
var media = CreateGeneratedMedia("Sony Text", "Hot");
var stream = media.Streams[0];
for (i=1; i <= 15; i++) {
var newEvent = new VideoEvent(cursorTimecode, stream.Length);
track.Events.Add(newEvent);
var take = new Take(stream);
newEvent.Takes.Add(take);
Vegas.Cursor = track.Length;
}
} catch (e) {
MessageBox.Show(e);
}
function FindSelectedTrack() : Track {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
if (track.Selected) {
return track;
}
trackEnum.moveNext();
}
return null;
}
Texte wrote on 6/20/2004, 2:25 PM
This good ;I' just to chang i<=15 if i have to do more.

Now i need to add some file to a selectrack.
I've find this in FAQs:

// edit the following line to suit your needs.
var filename = "D:\\video\\Tape 1 - Clip 001.avi";

var track = FindSelectedTrack();
if (null == track)
throw "no selected track";
var cursorTimecode = Vegas.Cursor;
var media = new Media(filename);
if (!media.IsValid())
throw "media file does not exist: " + filename;
var stream, newEvent;
if (track.IsAudio()) {
stream = media.Streams.GetItemByMediaType(MediaType.Audio, 0);
if (null == stream)
throw "media contains no audio streams";
newEvent = new AudioEvent(cursorTimecode, stream.Length);
} else {
stream = media.Streams.GetItemByMediaType(MediaType.Video, 0);
if (null == stream)
throw "media contains no video streams";
newEvent = new VideoEvent(cursorTimecode, stream.Length);
}
track.Events.Add(newEvent);
var take = new Take(stream);
newEvent.Takes.Add(take);

can you help me to keep it right ,I've do it but it never work.
It never add files to a select track.It's in erro when i've done.
I just copy it and paste to the file hat you've give me.


jetdv wrote on 6/20/2004, 7:16 PM
From what I can see, it looks right. I did not see the "import" statments. Are they on the top? What exactly is the error?
Texte wrote on 6/21/2004, 3:34 AM
Do you think with this on the top and it will run
import System;
import System.Collections;
import System.Text;
import System.IO;
import System.Drawing;
import System.Windows.Forms;
import Sony.Vegas;

I have I question,I use Visual Basic oftenly but I see that végas scripts is different .
can you let me know were can I find the explanation about the végas scripts
syntaxe ?
I like to do some scripts myself I don't want to download them frome the net.
Is it very different from javascript ?
Thanks
jetdv wrote on 6/21/2004, 6:19 AM
Yes. You MUST have the import lines on top.

The syntax can be found at the initial link I sent you. There is a link to the JScript pages on Microsoft's website. It is also possible to write scripts in VBScript but you'll find most examples are in JScript.
ezbob74 wrote on 7/28/2004, 11:39 PM
I get this error when i run the first or second script in this thread. what is the problem???


Compilation error on line 1:

Variable 'CreateGeneratedMedia' has not been declared


System.ApplicationException: Failed to compile script: 'C:\Program Files\Sony\Vegas 5.0\Script Menu\myscr.js'
at Sony.Vegas.ScriptHost.RunScript()
jetdv wrote on 7/29/2004, 6:31 AM
CreateGeneratedMedia is on line 1???? How about showing us the FULL script.

Also, check the import statment. If using Vegas 4, it should read SonicFoundry.Vegas; but for Vegas 5 it should read Sony.Vegas;