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