Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums VEGAS Pro Creating Simple Region through Script.

  • Creating Simple Region through Script.

    Posted by Frankie Jones on June 26, 2016 at 5:29 pm

    Hi,
    Not being very good at scripting, but does anybody know how to create a simple region that begins -0.5s from cursor position and ends +0.5s after cursor position?

    Wayne Waag replied 9 years, 10 months ago 2 Members · 1 Reply
  • 1 Reply
  • Wayne Waag

    June 26, 2016 at 8:22 pm

    Try this. Copy and save to a text file with a .cs extension. Then add to your script folder. I tested this in V9, V10, V12, and V13 and it seems to work. As written, it is set for an offset of .5 sec and length of 1.0 sec. These values can be changed.


    /*
    AddRegionAroundCursor.cs
    This script adds a region around the cursor. The user must specify both the region offset (region start time before the cursor) and
    length of the region in milliseconds. (Lines 18 and 19)
    Author: Wayne Waag
    Date: 6/26/2016
    */

    using Sony.Vegas;
    using System;

    namespace AddRegionAroundCursor
    {
    public class EntryPoint
    {
    public void FromVegas(Vegas vegas)
    {
    Double offset = 500; //number of milliseconds before cursor
    Double length = 1000; //length of region in milliseconds
    Timecode cursor = vegas.Transport.CursorPosition;
    Timecode regionstart = cursor - Timecode.FromMilliseconds(offset);
    Timecode regionlength = Timecode.FromMilliseconds(length);
    Region newRegion = new Region(regionstart,regionlength);
    vegas.Project.Regions.Add(newRegion);
    }
    }
    }

    wwaag

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