Applying EventFX to multiple events

Jim H wrote on 8/10/2008, 8:10 PM
I'm sure this has been answered before but the excellent forum search fails me. I want to apply a single EventFX to 60 or so events using a script of other batch process. Paste Event Attributes does not cut it because it over writes pan/crop and any other EventFX already on the other events. It would be simple to be able to highlight all of the events and set the properties for this EventFX to all. Anyone have a script for this? Thanks.

edit: I did find a script johnmeyer posted in 2006 over in the Scripts forum but I would be lost trying to figure out the syntax or what the parameter names are for the FX. I guess maybe I'm looking for a plug in or some feature in vegas that would bring up the FX dialog and just apply it to all highlighted clips.

Comments

PeterWright wrote on 8/10/2008, 8:48 PM
In the absence of a script, you could put all the events on a separate track then apply the FX at Track level.

Hopefully the Paste Event Attributes function will one day have a choice between Add & Replace existing settings.
Jim H wrote on 8/10/2008, 8:57 PM
The problem is I don't want the effect to be applied to the xfade between the two tracks. I'm using the NewBlue cartooner FX and it does weird things during the cross fades. I'm currently applying the FX once at the project level and I think applying it at the track level would be the same.

Here's the video in it's current form:

http://www.vimeo.com/Wakely08

I don't "hate" the effect during the xfades but it's unpredictable and abrupt at times.
PeterWright wrote on 8/10/2008, 9:22 PM
Yes, I see what you mean Jim. Have you tried the Luminance Transition - the Film Dissolve setting lets you choose between black or white dissolving first, which may help ....
Jim H wrote on 8/10/2008, 9:56 PM
I have to fix the FX to each event first, then I can apply the transition effect I want..otherwise CartoonR will just morph out the tweens... and yes, I like the Luminance transition and I'll probably go with that.
Thanks for the suggestions.
Grazie wrote on 8/10/2008, 11:19 PM
Jim, that's very well worth remembering, thanks,

Grazie
johnmeyer wrote on 8/11/2008, 10:21 AM
I never wrote a script to apply an effect to events. However, there are three excellent ways to do this. First, is Excalibur, which is what I use. Second, Ultimate S. Finally, there is the script below which lets you assign any fX and fX preset to all selected events. I assume that it will do exactly what you want. However, if you want support, and tons of other features, I highly recommend options one or two instead.
/*
* Copyright (c) 2004, Folding Rain Filmworks Inc.
*
* author: Joe Howes
*
* Coloring your final project in Vegas can be a bit of a bitch,
* espcially if you have a complex project divided into multiple
* sections. When you're going through and coloring, you may find
* that as you progress, coloring decisions you made early on
* just look lame, and going back and updating all of them is a
* pain in the ass because Vegas doesn't allow you to apply
* changes to multiple events or media at the same time...you have
* to go into each one individually.
*
* This script allows you to select one or more video events on the
* timeline and apply effects and presets to either the events
* themselves, or the media in the media pool. This script has
* saved me VAST amounts of time in finishing, and I hope it does
* the same for you.
*
* NOTE:
* - The reason you can't select items in the media pool and affect
* them directly is that in this version of Vegas (5.0b), the
* the scripting API doesn't allow you to check whether an item in
* the media pool is selected, so it would have to apply the effects
* to ALL media in the pool.
*
* - When affecting media, the effects are applied to all takes.
*
* - When affecting media, the algorithm is smart enough to check
* if a media pool item has already been affected and only process
* each one once.
*
* USAGE:
* Select one or more video events on the timeline and run the script.
* From the dialog choose one effect and (optional) preset at a time
* and click "Add Effect" to add it to the stack of effects that will
* be applied to all selected events or media. Choose whether to
* affect events or media, then click "Assign".
*
* v1.1: Sep. 24, 2004
*
* VERSION HISTORY:
*
* 1.1:
* - Added the option to add to existing FX as well as replace.
* - (Hopefully) fixed some GUI display issues...where labels were
* being truncated.
*/

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


/**
* MAIN
*/
try {

var fx = Vegas.VideoFX; // Vegas effects list
var done = false; // If nothing is done, let the user know
var plugInNameArray : ArrayList; // PlugIn names the user has chosen
var plugInFXArray : ArrayList; // The plugins associated with those names
var plugInPresetArray : ArrayList; // The presets associated with those plugins
var dlog = new FXReplacerDialog(); // The GUI


// Init
plugInFXArray = new ArrayList();


// Show the GUI
if (DialogResult.OK == dlog.ShowDialog()) {

// Get the user's choices
plugInNameArray = dlog.getPlugInNameArray();
plugInPresetArray = dlog.getPlugInPresetArray();

// Load the plugins the user has chosen
var e = new Enumerator(plugInNameArray);
while (!e.atEnd()) {
var plugInName = e.item();
e.moveNext();
var plugIn = fx.GetChildByName(plugInName);
if (null == plugIn) {
throw "could not find a plug-in named: '" + plugInName + "'";
}
plugInFXArray.Add(plugIn);
}

// Pass those plugins and the user's preset choices to either
// the event replacer or the media replacer
var replaceFX = dlog.replaceExistingFXCheck.Checked;
if (dlog.applyToEventsRadio.Checked) {
done = replaceSelectedEventFX(plugInFXArray, plugInPresetArray, replaceFX);
} else {
done = replaceSelectedMediaFX(plugInFXArray, plugInPresetArray, replaceFX);
}

}


// Only bother the user if no events or media were changed.
/*if (!done) {
MessageBox.Show("No events affected.", "Done!");
}*/

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


/**
* FUNCTION: replaceSelectedEventFX
* Iterate through all the video events and, if selected, remove all their
* FX plugins and replace with the user's selections.
*/
function replaceSelectedEventFX(plugInArray:ArrayList, presetArray:ArrayList, replaceFX) {

var done = false;

for (var track in Vegas.Project.Tracks) {

if (!track.IsVideo()) {
continue;
}


for (var evnt in track.Events) {
if (evnt.Selected) {
replaceEventFX(evnt, plugInFXArray, plugInPresetArray, replaceFX);
done = true;
}
}

}

return done;

}


/**
* FUNCTION: replaceSelectedMediaFX
* Iterate through all the video events and, if selected, remove all the plug-ins
* associated with their media pool entries and replace with the user's selections.
*/
function replaceSelectedMediaFX(plugInArray:ArrayList, presetArray:ArrayList, replaceFX) {

var done = false;
var affectedMedia : ArrayList = new ArrayList();

for (var track in Vegas.Project.Tracks) {

if (!track.IsVideo()) {
continue;
}

for (var evnt in track.Events) {

if (evnt.Selected) {
var e = new Enumerator(evnt.Takes);

// Iterate through ALL the takes for this event and replace
// the FX on their media pool entries.
while (!e.atEnd()) {
var take = e.item();
e.moveNext();
var media = take.Media;
if (affectedMedia.Contains(media)) {
continue;
}
replaceMediaFX(media, plugInFXArray, plugInPresetArray, replaceFX);
affectedMedia.Add(media);
done = true;
}
}

}

}

return done;

}


/**
* FUNCTION: replaceMediaFX
* Assign all the plug-ins from plugInArray, along with the presets in presetArray,
* to the media entity. Note that if the user chose not to specify a preset for a
* given plug-in, it's corresponding presetArray entry will be a null.
*/
function replaceMediaFX(media:Media, plugInArray:ArrayList, presetArray:ArrayList, replaceFX) {

if (replaceFX) {

var count = media.Effects.Count;

// Kill all the existing FX
while (count > 0) {
media.Effects.RemoveAt(0);
count = media.Effects.Count;
}

}

// Assign all the new FX
var e = new Enumerator(plugInArray);
var e2 = new Enumerator(presetArray);
while (!e.atEnd()) {
var plugIn = e.item();
e.moveNext();
var effect = new Effect(plugIn);
media.Effects.Add(effect);

var preset = e2.item()
e2.moveNext();

if (null != preset) {
effect.Preset = preset;
}
}

}


/**
* FUNCTION: replaceEventFX
* Assign all the plug-ins from plugInArray, along with the presets in presetArray,
* to the event entity. Note that if the user chose not to specify a preset for a
* given plug-in, it's corresponding presetArray entry will be a null.
*/
function replaceEventFX(evnt:VideoEvent, plugInArray:ArrayList, presetArray:ArrayList, replaceFX) {

if (replaceFX) {

var count = evnt.Effects.Count;

// Kill all the existing FX
while (count > 0) {
evnt.Effects.RemoveAt(0);
count = evnt.Effects.Count;
}

}

// Assign all the new FX
var e = new Enumerator(plugInArray);
var e2 = new Enumerator(presetArray);
while (!e.atEnd()) {
var plugIn = e.item();
e.moveNext();
var effect = new Effect(plugIn);
evnt.Effects.Add(effect);

var preset = e2.item()
e2.moveNext();

if (null != preset) {
effect.Preset = preset;
}
}

}



/**
* CLASS: FXReplacerDialog
* The GUI.
*/
class FXReplacerDialog extends Form {

var videoFXListBox : ListBox; // All Vegas' video FX will be listed here
var fxPresetListBox : ListBox; // All the presets
var finalApplicationListBox : ListBox; // All the user's choices

var applyToEventsRadio : RadioButton;
var applyToMediaRadio : RadioButton;
var replaceExistingFXCheck : CheckBox; // Replace or add to FX chain?

var addFXButton : Button;
var removeFXButton : Button;

var assignButton : Button;
var cancelButton : Button;

var videoFXParamGroup : GroupBox;
var fxPresetParamGroup : GroupBox;
var finalApplicationsParamGroup : GroupBox;

var presetList : ArrayList; // An ArrayList of ArrayLists holding presets
// for each plug-in
var plugInNameArray : ArrayList; // Contains the user's chosen plug-in names
var plugInPresetArray : ArrayList; // Contains the user's chosen preset names


/**
* CONSTRUCTOR
* Init everything.
*/
function FXReplacerDialog() {

this.Text = "Assign Plug-Ins to Selected Events or their Media";
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.StartPosition = FormStartPosition.CenterScreen;

plugInNameArray = new ArrayList();
plugInPresetArray = new ArrayList();

this.Width = 470;
this.Height = 480;


// VideoFX
this.videoFXListBox = new ListBox();
videoFXListBox.Location = new System.Drawing.Point(8, 18);
videoFXListBox.Name = "videoFXListBox";
videoFXListBox.Size = new System.Drawing.Size(200, 200);
videoFXListBox.TabIndex = 1;
videoFXListBox.add_Click(this.videoFXListBoxOnClick);

// VideoFX ParamGroup
videoFXParamGroup = new GroupBox();
videoFXParamGroup.Controls.Add(videoFXListBox);
videoFXParamGroup.Location = new System.Drawing.Point(8, 8);
videoFXParamGroup.Name = "videoFXParamGroup";
videoFXParamGroup.Size = new System.Drawing.Size(216, 225);
//videoFXParamGroup.TabIndex = -1;
videoFXParamGroup.TabStop = false;
videoFXParamGroup.Text = "Choose a Plug-In";

this.Controls.Add(videoFXParamGroup);


// FX Presets
this.fxPresetListBox = new ListBox();
fxPresetListBox.Location = new System.Drawing.Point(8, 18);
fxPresetListBox.Name = "fxPresetListBox";
fxPresetListBox.Size = new System.Drawing.Size(200, 200);
fxPresetListBox.TabIndex = 2;

// FX Presets ParamGroup
fxPresetParamGroup = new GroupBox();
fxPresetParamGroup.Controls.Add(fxPresetListBox);
fxPresetParamGroup.Location = new System.Drawing.Point(240, 8);
fxPresetParamGroup.Name = "fxPresetParamGroup";
fxPresetParamGroup.Size = new System.Drawing.Size(216, 225);
//fxPresetParamGroup.TabIndex = -1;
fxPresetParamGroup.TabStop = false;
fxPresetParamGroup.Text = "Choose a Preset (optional)";

this.Controls.Add(fxPresetParamGroup);


// Final Applications
this.finalApplicationListBox = new ListBox();
finalApplicationListBox.Location = new System.Drawing.Point(8, 18);
finalApplicationListBox.Name = "finalApplicationsListBox";
finalApplicationListBox.Size = new System.Drawing.Size(400, 100);
finalApplicationListBox.TabIndex = 5;

// Replace or Add?
replaceExistingFXCheck = new CheckBox();
replaceExistingFXCheck.Location = new System.Drawing.Point(25, 125);
replaceExistingFXCheck.Size = new System.Drawing.Size(125, 18);
replaceExistingFXCheck.Name = "replaceExistingFXCheck";
replaceExistingFXCheck.TabIndex = 6;
replaceExistingFXCheck.Checked = true;
replaceExistingFXCheck.Text = "Replace Existing FX";

// Events or Media Radios
applyToEventsRadio = new RadioButton();
applyToEventsRadio.Location = new System.Drawing.Point(160, 125);
applyToEventsRadio.Size = new System.Drawing.Size(120, 18);
applyToEventsRadio.Name = "applytoEventsRadio";
applyToEventsRadio.Checked = true;
applyToEventsRadio.TabIndex = 7;
applyToEventsRadio.Text = "Apply to Events";

applyToMediaRadio = new RadioButton();
applyToMediaRadio.Location = new System.Drawing.Point(280, 125);
applyToMediaRadio.Size = new System.Drawing.Size(120, 18);
applyToMediaRadio.Name = "applyToMediaRadio";
applyToMediaRadio.TabIndex = 8;
applyToMediaRadio.Text = "Apply to Media";

// Final Applications ParamGroup
finalApplicationsParamGroup = new GroupBox();
finalApplicationsParamGroup.Controls.Add(finalApplicationListBox);
finalApplicationsParamGroup.Controls.Add(replaceExistingFXCheck);
finalApplicationsParamGroup.Controls.Add(applyToEventsRadio);
finalApplicationsParamGroup.Controls.Add(applyToMediaRadio);
finalApplicationsParamGroup.Location = new System.Drawing.Point(25, 270);
finalApplicationsParamGroup.Name = "finalApplicationsParamGroup";
finalApplicationsParamGroup.Size = new System.Drawing.Size(436, 150);
//finalApplicationsParamGroup.TabIndex = 4;
finalApplicationsParamGroup.TabStop = false;
finalApplicationsParamGroup.Text = "FX to Assign";

this.Controls.Add(finalApplicationsParamGroup);


// Add Effect button
addFXButton = new Button();
addFXButton.Text = "Add Effect";
addFXButton.Left = 124;
addFXButton.Top = 240;
addFXButton.Width = 100;
addFXButton.add_Click(this.addFXOnClick);
addFXButton.Enabled = false;
addFXButton.TabIndex = 3;
Controls.Add(addFXButton);

// Remove Effect button
removeFXButton = new Button();
removeFXButton.Text = "Remove Effect";
removeFXButton.Left = 240;
removeFXButton.Top = 240;
removeFXButton.Width = 100;
removeFXButton.add_Click(this.removeFXOnClick);
removeFXButton.Enabled = false;
removeFXButton.TabIndex = 4;
Controls.Add(removeFXButton);

// Assign button
assignButton = new Button();
assignButton.DialogResult = System.Windows.Forms.DialogResult.OK;
assignButton.Text = "Assign";
assignButton.Left = 300;
assignButton.Top = 425;
AcceptButton = assignButton;
assignButton.TabIndex = 9;
Controls.Add(assignButton);

// Cancel button
cancelButton = new Button();
cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
cancelButton.Text = "Cancel";
cancelButton.Left = 380;
cancelButton.Top = 425;
CancelButton = cancelButton;
cancelButton.TabIndex = 10;
Controls.Add(cancelButton);


populate();

}


/**
* FUNCTION: populate
* Populates the data model with all of Vegas' plug-ins and presets.
*/
function populate() {

var fx = Vegas.VideoFX;
var plugInList = new ArrayList();
presetList = new ArrayList();

var e = new Enumerator(fx);
var first = true;
videoFXListBox.BeginUpdate();

// Get all the plug-ins
while (!e.atEnd()) {

if (first) {
first = false;
e.moveNext();
continue;
}

var plugIn = e.item();
e.moveNext();
plugInList.Add(plugIn.Name);

}

plugInList.Sort();

// Populate the videoFX list box and the presets data model
var e = new Enumerator(plugInList);

while (!e.atEnd()) {

var plugInName = e.item();
e.moveNext();
videoFXListBox.Items.Add(plugInName);

var plugIn = fx.GetChildByName(plugInName);
var presets : ArrayList = new ArrayList();
var e2 = new Enumerator(plugIn.Presets);

while (!e2.atEnd()) {
var preset = e2.item();
e2.moveNext();
presets.Add(preset.Name);
}
presetList.Add(presets);
}

videoFXListBox.EndUpdate();

}

/**
* FUNCTION: videoFXListBoxOnClick
* Event handler for clicks on the videoFXListBox. We update GUI buttons,
* populate the preset box.
*/
function videoFXListBoxOnClick(sender : Object, evt : System.EventArgs) {

var index = videoFXListBox.SelectedIndex;

// If there's at least one item selected in the list, enable the
// Add Effect button.
if (index != -1) {
addFXButton.Enabled = true;
}


// Get the presets for the chosen plug-in and populate the presets box.
var presets : ArrayList = presetList.Item(videoFXListBox.SelectedIndex);

fxPresetListBox.BeginUpdate();
fxPresetListBox.Items.Clear();

var e = new Enumerator(presets);

while (!e.atEnd()) {
var preset = e.item();
e.moveNext();
fxPresetListBox.Items.Add(preset);
}

fxPresetListBox.EndUpdate();

}


/**
* FUNCTION: addFXOnClick
* When the Add Effect button is clicked, reflect the user's choice
* both in the GUI and in the underlying data model.
*/
function addFXOnClick(sender: Object, evt : System.EventArgs) {

// Add the plug-in choice
var plugInName = videoFXListBox.SelectedItem.toString();
var presetIndex = fxPresetListBox.SelectedIndex;
var plugInPreset = null;
if (presetIndex != -1) {
plugInPreset = fxPresetListBox.SelectedItem.toString();
}

var displayString = new StringBuilder(plugInName);

// If a preset is chosen, add that too
if (presetIndex != -1) {
displayString.Append(" - <");
displayString.Append(plugInPreset);
displayString.Append(">");
}

finalApplicationListBox.Items.Add(displayString);

// Add the plug-in choice to the data model
plugInNameArray.Add(plugInName);

// If there is a preset choice, add that, otherwise add null
if (presetIndex != -1) {
plugInPresetArray.Add(plugInPreset);
} else {
plugInPresetArray.Add(null);
}

// If there is at least one item available in the FX to Assign box,
// enable the Remove Effect button
var removeEnabled = (finalApplicationListBox.Items.Count > 0) ? true : false;
removeFXButton.Enabled = removeEnabled;
}

/**
* FUNCTION: removeFXOnClick
* Remove the selected cohice from the FX to Assign box and from the data model.
*/
function removeFXOnClick(sender: Object, evt : System.EventArgs) {

// Remove from the data model
plugInNameArray.RemoveAt(finalApplicationListBox.SelectedIndex);
plugInPresetArray.RemoveAt(finalApplicationListBox.SelectedIndex);

// Remove from the GUI
finalApplicationListBox.BeginUpdate();
finalApplicationListBox.Items.Remove(finalApplicationListBox.SelectedItem);
finalApplicationListBox.EndUpdate();
var removeEnabled = (finalApplicationListBox.Items.Count > 0) ? true : false;
removeFXButton.Enabled = removeEnabled;
}

/**
* FUNCTION: getPlugInNameArray
* Accessor for the user's plug-in choices.
*/
function getPlugInNameArray() {
return plugInNameArray;
}

/**
* FUNCTION: getPlugInPresetArray
* Accessor for the user's preset choices.
*/
function getPlugInPresetArray() {
return plugInPresetArray;
}

}

JohnnyRoy wrote on 8/11/2008, 10:44 AM
> * Copyright (c) 2004, Folding Rain Filmworks Inc.

John, I assume you have the author's permission to post that here but please do him a big favor and take his email out of that post so he doesn't get spamed to death. ;-)

~jr
johnmeyer wrote on 8/11/2008, 11:37 AM
Good point about the email. I removed it. As to permission, I got this from a a public site, and there was no usage restriction posted, and I am not profiting in any way, nor is he selling anything (from his web site) that uses this code.

If he asks me to remove it, I certainly will do so.

P.S. [Edit] I emailed him (using the email address I just removed) and it bounced, so that email was no longer valid anyway.

Jim H wrote on 8/11/2008, 4:03 PM
Thanks John. I'll try this when I get back from this business trip. I'm assuming I just save the text file and rename the extension as a script and just run it from within vegas? Will it then prompt me which FX I want to run and which parameters? or do I need to edit the text of this scrpt?

btw...maybe it was another John who's 2006 post I was reading? :)
johnmeyer wrote on 8/11/2008, 5:10 PM
Just rename the file so it has the extension ".js"

It is a brilliant script because it loads all the fX and all the presets and then lets you choose which ones you want to apply. You can apply them either to the selected events or to media in the media pool. You can also choose to either replace existing fX, or else add to fX already assigned.

Pan/crop is not affected.

If you want to assign specific values for an fX, make sure to create a preset for that fX before you run this script.
Jim H wrote on 8/11/2008, 6:15 PM
This sounds like exactly what I'm looking for. Thanks so much.
Jim H wrote on 8/12/2008, 11:40 PM
John,
I love it! The script worked perfectly. What a handy tool. I'm rendering the new project in the morning and will post a link tomorrow. The cross fades are as they should be... no more blotchy mess. Thanks a ton.
Grazie wrote on 8/13/2008, 12:49 AM
Pan/crop is not affected. . . . .. loads all the fX and all the presets and then lets you choose which ones you want to apply

Oh yes! I'll need to experiment when I'm off the present "timed-project". Sounds perfect.

Thanks John.

Grazie

johnmeyer wrote on 8/13/2008, 10:30 AM
I can't say "you're welcome" because I didn't write it (note the author's name in the code). I tried several times to contact him, but so far no luck.
Jim H wrote on 8/13/2008, 4:57 PM
Much better: http://www.vimeo.com/1506167
johnmeyer wrote on 8/13/2008, 7:05 PM
Oooh, that's very cool.

Hope you don't mind, but I'm going to steal every effect II see in that video. I like it a LOT.
dcrandall wrote on 8/13/2008, 8:34 PM
Jim H,

I really enjoyed your video .... hope you don't mind if I use some of your creative ideas for my current project.
Is this a great forum or what!

-Dan
  • Velocity Micro Z55 Desktop Computer
  • ASUS Prime Z270M-Plus Motherboard
  • Intel(R) Core(TM) i7-7700K CPU @ 4.2GHz
  • Memory: 16GB DDR4-2400MHz
  • 4GB NVIDIA GeForce GTX 1050 Ti Driver Version: Studio Driver 452.06
  • Windows 10 Home 64bit v1909
  • Vegas Pro 18.0 Build 284
Grazie wrote on 8/13/2008, 10:44 PM
Jim! Great stuff. But I feel the REAL creativity is in your very "human" shot selection and precise concentration on that which takes/moves the story along. For me that is the USP. I liked the sounds of nature at the relevant quiet-down moments. Just sometimes I was wanting Cartoonr to move back into reality. I have further ideas on this.

Anyway, all very human, very like-able.

I also liked the coach and the wheels going up and down!

Grazie