Forum Replies Created

  • Jeremy Ashinghurst

    February 27, 2011 at 7:44 pm in reply to: Randomize clip order?

    I know this is a dead thread but today I had the same problem, about 50 clips that I wanted to randomize and I didn’t feel like installing a software pack to get this one thing done so . . . I wrote a script for it. I’ve never scripted in C# before so I’m sure it’s pretty ugly, but it gets the job done. it randomizes all the media events in a track by moving a random event to the current end of the track (but will not move linked audio and video tracks simultaneously). Of course i in no way gaurantee this script and recommend you duplicate the track you want to randomize prior to performing this script just to be safe.


    //*******************************************************************
    //* Program: Random Order
    //* Author: Jeremy Ashinghurst
    //* Updated: Feb 27 2011
    //* Description: randomly order clips from a selected track. clips will be successively placed at the end of the same track they are from. All clips from that track will be moved!
    //*------------------------------------------------------------------
    //* Copyright: none
    //*******************************************************************
    using System;
    using System.Diagnostics;
    using System.Windows.Forms;
    using Sony.Vegas;

    public class EntryPoint
    {
    public void FromVegas(Vegas vegas)
    {
    try
    {
    Track track = FindSelectedTrack(vegas);
    if (track != null)
    {
    if (track.Events.Count > 1)
    {
    Random RandomNumber = new Random();
    for (int x = track.Events.Count;x>0; x--)
    {
    int r = RandomNumber.Next(x);
    foreach(TrackEvent trackEvent in track.Events)
    {
    if (trackEvent.Index == r)
    {
    Timecode cliplength = trackEvent.Length;
    trackEvent.AdjustStartLength(track.Length,cliplength,false);
    }
    }
    }

    }
    else
    {
    MessageBox.Show("Track must have at least 2 events", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    }
    else
    {
    MessageBox.Show("You must select a track before running this script", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    }
    catch (Exception e)
    {
    MessageBox.Show(e.Message, "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
    }
    }

    ///

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy