Comments

jetdv wrote on 2/24/2012, 9:36 AM
Here's an old "FourPoints.js" script that you may be able to modify for your needs:

[code]
/**
* This script will set four points around the selection area on all selected tracks.
*
* Written By: Edward Troxel
* Copyright 2004 - JETDV Scripts
* Modified: 07-26-2005
**/

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;


//Change this line to change the distance between the points
var FPDist = new Timecode("00:00:01:00");


try {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());


//Now check for Volume Envelope
if (track.IsAudio() && track.Selected) {
// Find the volume envelope on this track - add if needed
var VolEnv = FindEnvelope(track, EnvelopeType.Volume);
if (null == VolEnv) {
VolEnv = new Envelope(EnvelopeType.Volume);
track.Envelopes.Add(VolEnv);
}

var ClipVol = VolEnv.ValueAt(Vegas.SelectionStart);
//Now set the points
SetPoint(VolEnv, Vegas.SelectionStart, ClipVol)
SetPoint(VolEnv, Vegas.SelectionStart + FPDist, ClipVol)
SetPoint(VolEnv, Vegas.SelectionStart + Vegas.SelectionLength - FPDist, ClipVol)
SetPoint(VolEnv, Vegas.SelectionStart + Vegas.SelectionLength, ClipVol)
}

trackEnum.moveNext();
}

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

function FindEnvelope(track : Track, etype : EnvelopeType) : Envelope {
var envEnum : Enumerator = new Enumerator(track.Envelopes);
while (!envEnum.atEnd()) {
var env : Envelope = envEnum.item();
if (env.Type == etype) {
return env;
}
envEnum.moveNext();
}
return null;
}

function SetPoint(menv : Envelope, PLoc : Timecode, PVal : Double) {
var a : EnvelopePoint = menv.Points.GetPointAtX(PLoc);

if (a == null) {
a = new EnvelopePoint(PLoc, PVal);
menv.Points.Add(a);
} else {
a.Y = PVal;
}
}
[/cod]