Is it possible to copy an FX chain from one clip to another via scripting? The only constructor I see for the Effect class creates a new default instance. I don't see any way to clone an Effect class into a new instance. Am I overlooking something?
No, there is no way to do this. I have often needed this ability. I've even suggested that the Script API use copy constructors so that you can pass in an existing object into a constructor and have the new class clone itself from that one. This would be perfect but the capability simply isn't there. :(
I came back to this issue again just to see if any new functionality was added. I actually found what "should" be a way to do this. But I'm getting an error.
There is a way through the baselist parent class to CopyTo all of the items in the list (in this case, the source Effects chain) to an Array. Then loop the array and insert the copies of the Effects into the target effects chain. Should work, and nearly does. But again, I'm getting an error on inserting the effects into the target.
Following is a script that's intended to copy track-level fx chain to each clip on the track. Everything works up to where I insert the copied Effect object into the target clip's Effects list. I get a weird error that says "System Argument Exception: Unknown effect plug-in". But if I show the effect plug-in name on the Effect object being copied, it looks fine. Also, if I create a new Effect using the plug-in name from the track-level object, it works and adds the correct effect type (except that's not what I want, I want the source effect, not a new effect).
Please take a look at this code and tell me if I'm just doing something wrong. I can't see anything that I could do differently.
To test, create a track with a few video clips. Add at least one effect at the track level. You should get an error. But comment the failing line and un-comment the line below it. It should work (at least create the same, but new default, named effects on the clips that were on the track level). It says when it fails that it doesn't recognize the plugin. But I can create a new effect using that plugin's name, and it works. Am I missing something obvious?
for ( var track in Vegas.Project.Tracks )
if (track.MediaType == MediaType.Video)
if ( track.Selected )
if ( track.Effects.Count > 0 )
for ( var evnt in track.Events )
var fx : System.Array = System.Array.CreateInstance(System.Object, track.Effects.Count);
track.Effects.CopyTo( fx, 0);
var fxEnum : Enumerator = new Enumerator(fx);
var i = 0;
while ( !fxEnum.atEnd() )
evnt.Effects.Insert( i++, fxEnum.item() ); // fails with "unknown effect plugin" (????)
//##### [following line works... but I want to copy the track effect, not a new effect] ######
//##### evnt.Effects.Insert( i++, new Effect( fxEnum.item().PlugIn ) );
So far, the Apply/Remove FX feature in Vegasaur's Effects window is one of the best when it comes to these questions.
If the ability to apply Filter Packages that are created in Vegas using the Apply / Remove FX feature of Vegasaur's Effects tab is added in the future, in addition to all the benefits offered by the feature, this will also make it possible to batch apply the Filter Packages on the level of media, since so far it is only possible to do this at the event level using the Vegas Plugin Manager.