-
scripting bug
it’s a long shot, but my brother has written this script for me, to make subclips out of regions, it also names them in a certain way and puts the subclips generated in a specific media bin…
it works, but sometimes takes an age, and sometimes crashes, (an exception has occurred),
then i try and reload the file, and i find that most files that i’ve saved after running the script won’t load, taking an age to get passed 85% or there abouts and finally saying again “an exception has occurred”
i need to perform this script 104 times in all so it needs to be solid… i wonder if any script writers out there can spot what’s bugging this script:
/**
* You can use this script to convert Vegas regions to subclips. It will only work with saved projects.
*
* To use this script:
*
* 1) Create named Vegas regions.
* 2) Confirm no overlapped regions.
* 3) Vegas>tools>scripting>run script>Convert Regions To Subclips.cs
* 4) Check Project Media to see the subclips
*
* Revision Date: June 22, 2008.
**/
using System;
using System.IO;
using System.Text;
using System.Collections;
using System.Windows.Forms;
using System.Globalization;
using Sony.Vegas;
public class EntryPoint
{
Vegas myVegas;
public void FromVegas(Vegas vegas) {
myVegas = vegas;
String projName;
String projFile = myVegas.Project.FilePath;
if ((null == projFile) || (String.Empty == projFile)) {
projName = “Untitled”;
} else {
projName = Path.GetFileNameWithoutExtension(projFile);
}
ConvertRegionsToSubclips();
}
void ConvertRegionsToSubclips() {
try {
/* foreach (Media media in myVegas.Project.MediaPool)
{
foreach (Region region in media.Regions)
{
//MessageBox.Show(media.FilePath);
//MessageBox.Show(region.Label);
Subclip subclip = new Subclip(myVegas.Project.FilePath, region.Position, region.Length, false, region.Label);
}
}*/
if (myVegas.Project.FilePath.Equals(“”))
MessageBox.Show(“Please save project before running this script”);
else
{
MediaBin InOrderBin = myVegas.Project.MediaPool.RootMediaBin;
bool foundIt = false;
foreach (MediaBin bin in myVegas.Project.MediaPool.RootMediaBin)
{
if (bin.Name.Equals(“in order”))
{
InOrderBin = bin;
foundIt = true;
}
}
if (foundIt)
{
String suffix = “”;
foreach (Region region in myVegas.Project.Regions)
{
//MessageBox.Show(myVegas.Project.FilePath);
//MessageBox.Show(region.Label);
String subclipLabel;
if (suffix.Equals(“”))
{
subclipLabel = region.Label;
suffix = region.Label.Substring(1);
}
else
subclipLabel = region.Label + suffix;
Subclip subclip = new Subclip(myVegas.Project.FilePath, region.Position, region.Length, false, subclipLabel);
InOrderBin.Add(subclip);
}
}
else
{
MessageBox.Show(“Cannot find media bin \”in order\””);
}
}
} finally {
}
}
}