Random Transition for my stills

sanju wrote on 11/15/2003, 11:17 AM
Please help and may thanks

I have about 100 pictures i want to ad random transitions to and would like a script to save me hours putting them in one by one.

I found the script below but it tells me there is error at line 67 - curvetype has not been declared.

Please help me.



/**
* Apply Transition to Adjacent Video events and optionally move
* events to overlap events.
*
* For use with Sonic Foundry Vegas Video 4.0
*
* Copyright 2002 murkWare (mj@sightworks.com)
**/
import System.Windows.Forms;
import SonicFoundry.Vegas.Script;
var overlapTime = 1000;

var dialog = new TransitionDialog(overlapTime);
var bFade = false; //Only true if the second list item is chosen
var bRandom = false; //Only true if the first list item is chosen
dialog.m_transList.Items.Add("Random For each event")
dialog.m_transList.Items.Add("Standard Cross Fade")
var count = 0;
var totalTrans = Vegas.Transitions.Count;
var num;
var transEnum = new Enumerator(Vegas.Transitions);
while (!transEnum.atEnd())
{
var trans = transEnum.item();
if(count > 0)
dialog.m_transList.Items.Add(trans.Name);
count++;

transEnum.moveNext();
}
try
{
dialog.m_transList.SelectedIndex = 0
var dialogResult = dialog.ShowDialog();
var iTrans = int(dialog.m_transList.SelectedIndex);
if(System.Windows.Forms.DialogResult.OK == dialogResult)
{
if (iTrans == 0)
{
bRandom = true;
}
else if(iTrans == 1)
{
bFade = true
}

var plugIn;
if(iTrans > 1)
{
plugIn = Vegas.Transitions.GetChild(int(iTrans -1));
}

overlapTime = int(dialog.overlapTimeBox.Text);
var startoffset = overlapTime;
var trackEnum = new Enumerator(Vegas.Project.Tracks);
var fx;

while (!trackEnum.atEnd())
{
var tr = trackEnum.item();
var eventEnum = new Enumerator(tr.Events);

while (!eventEnum.atEnd())
{
var ev = eventEnum.item();

ev.FadeIn.Curve = CurveType.Fast;
if(bRandom)
{
num = int(Math.random() * totalTrans + 1);
if (num > 23)
{
num = totalTrans - 1;
}
plugIn = Vegas.Transitions.GetChild(int(num));
}


var startTime = new Timecode(ev.Start);
var length = new Timecode(ev.Length);
startTime.Subtract(startoffset);
ev.AdjustStartLength(startTime,length,true);
Vegas.UpdateUI();
if(ev.MediaType == MediaType.Video && !bFade)
{
fx = new Effect(plugIn);
ev.FadeIn.Transition = fx;
}
eventEnum.moveNext();
startoffset = startoffset + overlapTime;
}
startoffset = overlapTime;
trackEnum.moveNext();
}
}
} catch (e)
{
MessageBox.Show(e + "\n\nReport this error to mj@sightwork.com\n\n" + num);
}
// Form subclass that is the dialog box for this script
class TransitionDialog extends Form {

var overlapTimeBox;
var m_transList;

function TransitionDialog(overlapTime) {
this.Text = "Add Transitions to adjacent events";
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.StartPosition = FormStartPosition.CenterScreen;
this.Width = 480;
this.Height = 120;

var buttonWidth = 80;
var buttonHeight = 24;
var buttonTop = 60;

overlapTimeBox = addTextControl("Overlap Time (ms)", 320, 140, 20, overlapTime.ToString());
m_transList = addComboBox(20,80,20);

var okButton = new Button();
okButton.Text = "OK";
okButton.Left = this.Width - ((buttonWidth+10));
okButton.Top = buttonTop;
okButton.Width = buttonWidth;
okButton.Height = buttonHeight;
okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
AcceptButton = okButton;
Controls.Add(okButton);

var label = new Label();
label.AutoSize = true;
label.Text = "Copyright 2003 murkWare"
label.Left = 20;
label.Top = 80;
Controls.Add(label);
}

function addTextControl(labelName, left, width, top, defaultValue) {
var label = new Label();
label.AutoSize = true;
label.Text = labelName + ":";
label.Left = left;
label.Top = top + 4;
Controls.Add(label);

var textbox = new TextBox();
textbox.Multiline = false;
textbox.Left = label.Right;
textbox.Top = top;
textbox.Width = width - (label.Width);
textbox.Text = defaultValue;
Controls.Add(textbox);

return textbox;
}

function addComboBox(left,width,top)
{

var transList = new ComboBox();

// transList.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
// Or System.Windows.Forms.AnchorStyles.Right)
transList.DropDownWidth = width;
// transList.Items.AddRange(tem 5"});
transList.Location = new System.Drawing.Point(left, top);
transList.Size = new System.Drawing.Size(280, 21);
transList.TabIndex = 7;
Controls.Add(transList);

return transList;
}

}

Comments

jetdv wrote on 11/15/2003, 9:32 PM
Try this one instead:

applytransitions.js
sanju wrote on 11/16/2003, 6:32 PM
jUST WHAT I HAVE BEEN LOOKING FOR.

tHANKS A LOT.
andydreisch wrote on 11/18/2003, 11:24 AM
Hi sanju, were you able to make this script work as is?

jetdv, I tested the script on a simple test VEG containing about 16 adjacent video events. It appeared to have no effect when I specified either random, cross-fade, or a specific transition. It also didn't matter what time (milliseconds) I specified.

However, when I reviewed the script there were comments in seemingly critical parts dealing with event start/end time adjustments. When I uncommented all comments, changes seem to take effect ... but the timeline was incorrectly adjusted. I had to undo.

I haven't spent but 10 minutes looking at this problem so far.

I wonder if there is a newer version? If not, I'll attempt to fix the script and re-post. I also wonder if I'm simply doing something wrong.

Thanks, jetdv, for this script.
jetdv wrote on 11/18/2003, 12:10 PM
The original script was written for the Vegas 4 BETA. I simply modified it to "work" with the release version. However, I DID comment out the auto overlapping portion so that box on the GUI is meaningless. Overlap the events first and then run the script. Each transition should then get a random selection.

The commenting was more of a "speed and ease of updating" thing. If you want to make the overlapping work again, feel free to debug that code as well. I didn't write the original script so I didn't feel it was completely my place to update it. Besides, I can already overlap using Excalibur's Gap Wizard.
andydreisch wrote on 11/18/2003, 5:04 PM
Thanks for feedback. I've purchased Excalibur, too. Thanks for tip.
sanju wrote on 11/22/2003, 9:49 AM
yep worked for me, but like jetdv said it may be coz i have my stills overlaped first then i run the script.
sanju wrote on 12/16/2003, 3:28 PM
JETDV: applytransitions.js

This script dose give ramdom transitions but not ALL the transitions are included in the slide show. I think only the first few come up.
jetdv wrote on 12/16/2003, 8:28 PM
I didn't write it - I just corrected it to run in the release version. Having said that, a quick perusal of the code looks like it will use every type of transition, just not every variety within that type. You only get the "default" version.
murk wrote on 12/18/2003, 9:31 PM
Hello, my name is Murk and I am the original author of the random transition script. I have fixed the issue you have discussed here. The problem had to do the with the ruler format. I now automatically set the ruler format to 'Absolute Frames' and restore it to your preference when the script finishes. You'll notice that the overlap time is no longer in millisecond, but in frames.

get it here: ApplyTransition 1.1
rakesh-s wrote on 8/26/2017, 1:30 AM

Hello my all dear friends, Thanks to share this script, But i am really newbie for vegas, I don't know how to use / run this script, please help me, Thanks a lot

jetdv wrote on 8/28/2017, 9:34 AM

Download the script I linked to in the second post. Place it in the "Script Menu" folder for the version of Vegas you have under Program Files\(proper folder for your version of Vegas). Then modify it for the version of Vegas you have by changing "SonicFoundry" to either "Sony" or "ScriptPortal".

ringostarrr wrote on 12/7/2017, 5:40 PM

Download the script I linked to in the second post. Place it in the "Script Menu" folder for the version of Vegas you have under Program Files\(proper folder for your version of Vegas). Then modify it for the version of Vegas you have by changing "SonicFoundry" to either "Sony" or "ScriptPortal".

Hello jetdv,

I am running Sony Vegas Pro 13 and am looking to apply random transitions across my many still pictures. I came across the script you posted "ApplyTransV5.js" but am running into errors. I was able to get the code to work on the first few pictures but then the code stopped and an error appears. Also, there is a gap between the pictures at where the code stopped.

The error I received is "Error: Error HRESULT E_FAIL has been returned from a call to a COM component."

Please help as these are for my wedding slideshow that I am preparing soon.

@jetdv