Hello. I'm currently learning how to write some scripts for vegas 16, and one thing that I have been struggling to find is how to add effects and fx chains programatically . I have looked at the documentation and I am aware that I need to use:
override void Insert
(
Int32 index,
Effect item)
However, how do I actually get the instance for this effect so that I can add as a parameter, and is there a way to read in this effect object from an XML file containing the effect? Sorry if this is a terrible question but I'm not really familiar with using api's. Thanks in advance for any help.
Here is my current code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;using System.Windows.Forms;
using ScriptPortal.Vegas;namespace Nitty_Pro_18
{
// Entry point
public class EntryPoint
{
// Run function once vegas has provided instance of itself
public void FromVegas(Vegas vegas)
{
// Get the first track
Track myTrack = vegas.Project.Tracks[0];// For each marker in the project file
foreach(Marker marker in vegas.Project.Markers)
{
// Check each track event to see if one occurs during this marker
foreach (VideoEvent videoEvent in myTrack.Events)
{
if(videoEvent.Start <= marker.Position && videoEvent.End >= marker.Position)
{
// Marker is over a valid event
// Check the label of the marker// If the label is "k", then we will add a kill effect
if (marker.Label.ToLower() == "k")
{
// Split the event at the position of the marker
videoEvent.Split(marker.Position - videoEvent.Start);// Clear video effects and add an FX chain
videoEvent.Effects.Clear();
videoEvent.Effects.Insert(marker.Position - videoEvent.Start, );
}// If the label is "t", then we will add a transition
else if (marker.Label.ToLower() == "t")
{}
}
}
// else ignore marker
}}
}}