FORUMS: list search recent posts

Creating Simple Region through Script.

COW Forums : VEGAS Pro

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Frankie Jones
Creating Simple Region through Script.
on Jun 26, 2016 at 5:29:36 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?


Return to posts index

Wayne Waag
Re: Creating Simple Region through Script.
on Jun 26, 2016 at 8:22:40 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]