Finding All Transitions in the Project in Vegas Pro

In this tutorial we look for all transitions in the project. We see how to list all transitions in a dialog box and also how to place regions around each transition and name the region the same as the transition name.

https://www.vegascreativesoftware.info/us/forum/find-and-locate-all-transitions-in-a-project–146712

What scripts would you like to see? Any processes you’d like to see how to do using a script?

2 thoughts on “Finding All Transitions in the Project in Vegas Pro”

  1. Edward,
    I’ve written a script to apply Transition selected video events. It works OK but I would like to open Vegas Transition Properties window at the end to adjust parameters. InVegas I click right button on the event Transition field and select Transition Properties from the popup menu. Can I do it from a script?
    Thank you,
    Gregory
    *************************
    /**
    * Script to test Transition UI
    * Revision Sept 22, 2024
    **/

    using System;
    using System.Text;
    using System.Drawing;
    using System.Collections.Generic;
    using System.Windows.Forms;
    using ScriptPortal.Vegas;

    public class EntryPoint {

    Vegas myVegas = null;
    List SelectedVideoEvents = null;
    TreeView trvTransitions = null;

    public void FromVegas(Vegas vegas)
    {
    myVegas = vegas;
    SelectedEvents();
    FillTransitions();
    DialogResult result = ShowUI();
    myVegas.UpdateUI();
    if (DialogResult.OK == result) SetTransition();
    }

    //******************
    // Functions
    //******************

    void SelectedEvents()
    {
    SelectedVideoEvents = new List();
    foreach (Track track in myVegas.Project.Tracks)
    {
    if (track.MediaType == MediaType.Video)
    {
    foreach (TrackEvent tre in track.Events) if (tre.Selected) SelectedVideoEvents.Add((VideoEvent)tre);
    }
    }
    }

    void FillTransitions()
    {
    trvTransitions = new TreeView();
    trvTransitions.Top = 10;
    trvTransitions.Left = 10;
    trvTransitions.Height = 350;
    trvTransitions.Width = 200;
    trvTransitions.Nodes.Clear();
    TreeNode tn = null;
    TreeNode tnVegRoot = new TreeNode(“VEGAS”);
    trvTransitions.Nodes.Add(tnVegRoot);
    foreach (PlugInNode tran in myVegas.Transitions)
    {
    string sName = tran.Name;
    if (sName.Contains(“VEGAS”))
    {
    tn = tnVegRoot.Nodes.Add(sName, sName.Replace(“VEGAS”, string.Empty));
    foreach (EffectPreset ep in tran.Presets) tn.Nodes.Add(ep.Name, ep.Name);
    }
    }
    tnVegRoot.Expand();
    }

    void SetTransition()
    {
    if(SelectedVideoEvents.Count > 0 && trvTransitions.SelectedNode != null && trvTransitions.SelectedNode.Level == 2) //Selected node – Preset
    {
    string traName = trvTransitions.SelectedNode.Parent.Name; //Transition
    string presName = trvTransitions.SelectedNode.Name; //Preset
    MessageBox.Show(“Transition: ” + traName + ” – ” + presName);

    Timecode tcFade1 = Timecode.FromMilliseconds(1000); //1 sec
    Timecode tcFade2 = Timecode.FromMilliseconds(500); //Middle of Fade
    PlugInNode tran = myVegas.Transitions.GetChildByName(traName);
    Effect eff = new Effect(tran);
    SelectedVideoEvents[0].FadeIn.Length = tcFade1; //FadeIn transition 1 sec
    SelectedVideoEvents[0].FadeIn.Transition = eff;
    eff.Preset = presName;
    myVegas.Cursor = SelectedVideoEvents[0].Start + tcFade2; //Place cursor in the middle of the transition to adjust parameters

    //Works for effects but NOT for transition!
    //SelectedVideoEvents[0].OpenVideoEffectUI(); // How to open Transition Properties UI ?
    }
    else MessageBox.Show(“Wrong selection!”);
    }

    //******************
    // UI Functions
    //******************

    DialogResult ShowUI()
    {
    Form dlog = new Form();
    String msg = null;
    if (SelectedVideoEvents.Count == 0) msg = “No events selected \n” + “Cancel script and try again.”;
    else msg = SelectedVideoEvents.Count.ToString() + ” events selected \n” + “Select a transition and click OK to proceed”;

    dlog.Text = “Test Transition UI 1 sec FadeIn”;
    dlog.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
    dlog.MaximizeBox = false;
    dlog.StartPosition = FormStartPosition.CenterScreen;
    dlog.Width = 510;
    dlog.ControlBox = false;

    int titleBarHeight = dlog.Height – dlog.ClientSize.Height;
    int btnWidth = 80;
    int btnHeight = 30;
    int top1 = 10;
    int top2 = top1 + 24;
    int top3 = top2 + 36;
    int top4 = 400;

    dlog.Controls.Add(trvTransitions);

    Button btnOK = AddButton(“OK”, 250, top3, btnWidth, btnHeight);
    btnOK.Enabled = (SelectedVideoEvents.Count > 0);
    btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
    dlog.AcceptButton = btnOK;
    dlog.Controls.Add(btnOK);
    Button btnCancel = AddButton(“Cancel”, 250 + btnWidth + 12, top3, btnWidth, btnHeight);
    btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    dlog.CancelButton = btnCancel;
    dlog.Controls.Add(btnCancel);

    Label lblInfo = AddInfoLabel(msg, top4, 6, dlog.Width – 15);
    dlog.Controls.Add(lblInfo);
    dlog.Height = lblInfo.Bottom + 40;
    return dlog.ShowDialog(myVegas.MainWindow);
    }

    Label AddInfoLabel(String text, int top, int left, int width)
    {
    Label lblInfo = new Label();
    lblInfo.AutoSize = false;
    lblInfo.Text = text;
    lblInfo.Left = left;
    lblInfo.Width = width;
    lblInfo.Top = top;
    lblInfo.Height = 52;
    lblInfo.BorderStyle = BorderStyle.FixedSingle;
    lblInfo.BackColor = Color.Yellow;
    return lblInfo;
    }

    Button AddButton(String text, int left, int top, int width, int height)
    {
    Button btn = new Button();
    btn.Text = text;
    btn.Left = left;
    btn.Top = top;
    btn.Width = width;
    btn.Height = height;
    btn.Enabled = true;
    return btn;
    }
    }

Leave a Reply