Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums VEGAS Pro FourPoints Script Not Working

  • FourPoints Script Not Working

    Posted by Bill Cortez on February 19, 2009 at 5:11 am

    I’m using Vegas Pro 8c and I can’t get Edward Troxel’s FourPoints script to run (I saved it as a .cs file, I also tried .js). I get an error message that says: “Exception thrown by message called.”
    In the details it says in part: “System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ApplicationException: Failed to add envelope point (point may already exist at that location).
    at Sony.Vegas.EnvelopePoint.AddSelf(IEnvelopeOwner owner, EnvelopeType type)”

    I can run the scripts that came with the installation. Thanks, Bill.

    Bill Cortez replied 17 years, 5 months ago 3 Members · 3 Replies
  • 3 Replies
  • John Rofrano

    February 19, 2009 at 12:41 pm

    > Failed to add envelope point (point may already exist at that location).

    Do you have an envelope point at the location already? I’m not familiar with the script but I assume you must first make a timeline selection and then it creates a 4-point envelope within the selection. Perhaps you didn’t make a timeline selection first? If you can point me to the script, I can take a look for you.

    ~jr

    http://www.johnrofrano.com
    http://www.vasst.com

  • Edward Troxel

    February 19, 2009 at 2:34 pm

    Here’s the current version of that script for Vegas Pro 8.

    /**
    * This script will set four points around the selection area on all selected tracks.
    *
    * Written By: Edward Troxel
    * Copyright 2004-2009 - JETDV Scripts
    * Modified: 07-18-2006
    **/

    using System;
    //using System.IO;
    //using System.Windows.Forms;
    using Sony.Vegas;

    public class EntryPoint
    {
    Vegas myVegas;

    public void FromVegas(Vegas vegas)
    {
    myVegas = vegas;

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

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

    double ClipVol = VolEnv.ValueAt(myVegas.SelectionStart);
    //Now set the points
    SetPoint(VolEnv, myVegas.Transport.LoopRegionStart, ClipVol);
    SetPoint(VolEnv, myVegas.Transport.LoopRegionStart - FPDist, ClipVol);
    SetPoint(VolEnv, myVegas.Transport.LoopRegionStart + myVegas.Transport.LoopRegionLength + FPDist, ClipVol);
    SetPoint(VolEnv, myVegas.Transport.LoopRegionStart + myVegas.Transport.LoopRegionLength, ClipVol);
    }
    }
    }

    private Envelope FindEnvelope(Track track, EnvelopeType etype)
    {
    foreach(Envelope env in track.Envelopes)
    {
    if (env.Type == etype)
    {
    return env;
    }
    }
    return null;
    }

    private void SetPoint(Envelope menv, Timecode PLoc, double PVal)
    {
    EnvelopePoint a = menv.Points.GetPointAtX(PLoc);

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

    }

    Just save it as “FourPoints.cs” and it should do the job for you. You do need to have a selection area (it will still work even if you don’t but won’t give you what you want) and a selected audio track.

    Edward Troxel
    JETDV Scripts

  • Bill Cortez

    February 19, 2009 at 4:36 pm

    Thanks Ed, I had the audio track and the event selected, but I didn’t make a selection area–that did the trick. Cool, your script will save me a lot of time editing, appreciate it a lot. Bill.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy