Comments

JohnnyRoy wrote on 7/15/2010, 8:51 PM
> I am wondering if there is something that I can use to set all effects (on a track) to none at my cursor position

Hi Keith,

Wonder no more... Try this script that's hand crafted to your specifications. ;-)

Just select the video track and position the timeline cursor at place you want to reset the FX and it should do what you want (note it will only work for Video FX that have a "Reset to None" preset which should be all of the Sony FX but you can always make one if it doesn't exist. Also note that the preset name is case sensitive!):


//****************************************************************************
//* Program: Reset TrackFX to None.cs
//* Author: John Rofrano
//* Description: This script sets Video Track FX keyframes to None at the
//* current timeline cursor position
//* Created: July 15, 2010
//* Last Updated: July 18, 2010 - Added ability to update existing keyframe
//* Copyright: (c) 2010, Sundance Media Group / VASST. All Rights Reserved
//****************************************************************************
using System;
using System.Collections;
using System.Windows.Forms;
using Sony.Vegas;

class EntryPoint
{
public void FromVegas(Vegas vegas)
{
try
{
// get the selected video track
VideoTrack videoTrack = FindSelectedVideoTrack(vegas.Project);
if (videoTrack == null)
{
throw new ApplicationException("You must select a video track.");
}

// create keyframes for all effects as "Reset to None"
foreach (Effect effect in videoTrack.Effects)
{
Keyframe resetToNone = FindOrAddKeyframe(effect, vegas.Transport.CursorPosition);
resetToNone.Type = VideoKeyframeType.Hold;
resetToNone.Preset = "Reset to None";
}
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Reset TrackFX to None", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

/// <summary>
/// Finds the first selected video track
/// </summary>
/// <returns>The first selected video track or null if no video track is selected</returns>
private VideoTrack FindSelectedVideoTrack(Project project)
{
foreach (Track track in project.Tracks)
{
if (track.IsVideo() && track.Selected)
{
return track as VideoTrack;
}
}

return null; // we didn't find one
}

/// <summary>
/// Finds the keyframe at the position or adds a new one if one doesn't exist
/// </summary>
/// <param name="effect">The effect to find the keyframe</param>
/// <param name="position">The position of the keyframe</param>
/// <returns></returns>
private Keyframe FindOrAddKeyframe(Effect effect, Timecode position)
{
foreach (Keyframe keyframe in effect.Keyframes)
{
if (keyframe.Position == position)
{
return keyframe;
}

// if we are past the position just break out of the loop
if (keyframe.Position > position)
{
break;
}
}

// didn't find one so create one
Keyframe newKeyframe = new Keyframe(position);
effect.Keyframes.Add(newKeyframe);

return newKeyframe;
}
}


Here is another version to do the same at the Event level:


//****************************************************************************
//* Program: Reset EventFX to None.cs
//* Author: John Rofrano
//* Description: This script sets a Event VideoFX keyframe to None at the cursor
//* Created: July 15, 2010
//* Last Updated: July 18, 2010 - Added ability to update existing keyframe
//* Copyright: (c) 2010, Sundance Media Group / VASST. All Rights Reserved
//****************************************************************************
using System;
using System.Collections;
using System.Windows.Forms;
using Sony.Vegas;

class EntryPoint
{
public void FromVegas(Vegas vegas)
{
try
{
// get the selected event
VideoEvent videoEvent = FindSelectedVideoEvent(vegas.Project);
if (videoEvent == null)
{
throw new ApplicationException("You must select a video event.");
}

// calculate the cursor position relative to the event start
Timecode position = vegas.Transport.CursorPosition - videoEvent.Start;

// create keyframes for all effects as "Reset to None"
foreach (Effect effect in videoEvent.Effects)
{
Keyframe resetToNone = FindOrAddKeyframe(effect, position);
resetToNone.Type = VideoKeyframeType.Hold;
resetToNone.Preset = "Reset to None";
}
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Reset EventFX to None", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

/// <summary>
/// Finds the first selected video event
/// </summary>
/// <returns>The first selected video event or null if no video event is selected</returns>
private VideoEvent FindSelectedVideoEvent(Project project)
{
foreach (Track track in project.Tracks)
{
if (!track.IsVideo()) continue; // only process video tracks

foreach (VideoEvent videoEvent in track.Events)
{
if (videoEvent.Selected)
{
return videoEvent;
}
}
}

return null; // we didn't find one
}

/// <summary>
/// Finds the keyframe at the position or adds a new one if one doesn't exist
/// </summary>
/// <param name="effect">The effect to find the keyframe</param>
/// <param name="position">The position of the keyframe</param>
/// <returns></returns>
private Keyframe FindOrAddKeyframe(Effect effect, Timecode position)
{
foreach (Keyframe keyframe in effect.Keyframes)
{
if (keyframe.Position == position)
{
return keyframe;
}

// if we are past the position just break out of the loop
if (keyframe.Position > position)
{
break;
}
}

// didn't find one so create one
Keyframe newKeyframe = new Keyframe(position);
effect.Keyframes.Add(newKeyframe);

return newKeyframe;
}
}

Edit: Added two versions, one for tracks one for events.
Updated 2010-07-18: Added the ability to update existing keyframes

~jr
Byron K wrote on 7/15/2010, 8:59 PM
If this script works it will be very handy indeed. I've been resetting effects by splitting the event, deleting the effects chain and re-inserting an effect chain w/ default settings.

I'll definately have to try it out.!

Thanks!
Byron
JohnnyRoy wrote on 7/15/2010, 9:07 PM
Yea, I originally wrote it for events and then realized that Keith wanted it at the track level so I posted both versions. Enjoy,

~jr
Cooldraft wrote on 7/15/2010, 9:23 PM
You are amazing not I wish I could try it .....but I am 4 hours in a winter 'render'land. :)
Cooldraft wrote on 7/17/2010, 11:46 AM
This works great but it seems to be additive. If there is already a key frame there it just adds another right on top...maybe I will take note and delete when going through and tweaking.
JohnnyRoy wrote on 7/18/2010, 7:26 AM
> This works great but it seems to be additive. If there is already a key frame there it just adds another right on top...maybe I will take note and delete when going through and tweaking.

OK, I update both scripts to update the current keyframe if found, instead of adding a new one.

~jr
Byron K wrote on 7/18/2010, 2:30 PM
Awesome! Thanks JohnnyRoy!
Cooldraft wrote on 7/20/2010, 11:24 AM
Yes, awesome indeed. Thank you very much.
Cooldraft wrote on 8/11/2010, 12:17 PM
Just looking around and I saw this-any word?