Add regions to events..?

Gid wrote on 5/1/2025, 3:56 PM

Hi, I'm trying to get a script working I found online that adds regions to the events on the timeline but I keep getting the msg missing pop-up, to be honest I haven't got a clue how to fix this. Can someone help pls.

(This is that second one 'I come from the future' in that link)

AddRegionsToEvents.js

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;
var evnt : TrackEvent;
var myRegion : Region;
try {
//Find the selected event
var track = FindSelectedTrack();
if (null == track)
throw "no selected track";
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
myRegion = new Region(evnt.Start,evnt.Length,evnt.ActiveTake.Name); 
Vegas.Project.Regions.Add(myRegion);
eventEnum.moveNext();
}
} catch (e) {
MessageBox.Show(e);
}
function FindSelectedTrack() : Track {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
if (track.Selected) {
return track;
}
trackEnum.moveNext();
}
return null;
}

 

Vegas Pro 18 - 22
Vegas Pro/Post 19
Boris Continuum & Sapphire, 
Silhouette Standalone + Plugin, 
Mocha Pro Standalone + Plugin, 
Boris Optics,
NewBlue TotalFX
Desktop PC Microsoft Windows 10 Pro - 64-Bit
ASUS PRO WS WRX80E-SAGE SE WIFI AMD Motherboard
AMD Ryzen Threadripper PRO 3975WX 3.5GHz 32 Core
Corsair iCUE H150i RGB PRO XT 360mm All-in-One Liquid CPU Cooler
RAM 256GB ( 8x Micron 32GB (1x 32GB) 2666MHz DDR4 RAM )
2x Western Digital Black SN850 2TB M.2-2280 SSD, 7000MB/s Read, 5100MB/s Write
(programs on one, project files on the other)
Graphics MSI GeForce RTX 3090 SUPRIM X 24GB OC GPU
ASUS ROG Thor 1200W Semi-Modular 80+ Platinum PSU 
Fractal Design Define 7 XL Dark TG Case with 3 Fans
Dell SE3223Q 31.5 Inch 4K UHD (3840x2160) Monitor, 60Hz, & an Acer 24" monitor.

At the moment my filming is done with a Samsung Galaxy S23 Ultra 5G & a GoPro Hero11 Black

I've been a Joiner/Carpenter for 40yrs, apprentice trained time served, I don't have an apprentice of my own so to share my knowledge I put videos on YouTube.

YouTube videos - https://www.youtube.com/c/Gidjoiner

 

Comments

john_dennis wrote on 5/1/2025, 4:29 PM

The Shadetree Script-Chaser SWAGs:

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;

I'm guessing that referring to Sony.Vegas is dated if you are using Magix versions. Perhaps you can find a more modern script to copy from to get you started.

Gid wrote on 5/1/2025, 4:33 PM

@john_dennis Thanks, yep. That one is dated 2024 but -

February 24, 2024 at 12:25 pm

I come from the future, with an update for anyone trying to do this. I ran this in my antique Vegas Pro 9 and it worked great, turning events to regions and retaining the active take name.

Vegas Pro 18 - 22
Vegas Pro/Post 19
Boris Continuum & Sapphire, 
Silhouette Standalone + Plugin, 
Mocha Pro Standalone + Plugin, 
Boris Optics,
NewBlue TotalFX
Desktop PC Microsoft Windows 10 Pro - 64-Bit
ASUS PRO WS WRX80E-SAGE SE WIFI AMD Motherboard
AMD Ryzen Threadripper PRO 3975WX 3.5GHz 32 Core
Corsair iCUE H150i RGB PRO XT 360mm All-in-One Liquid CPU Cooler
RAM 256GB ( 8x Micron 32GB (1x 32GB) 2666MHz DDR4 RAM )
2x Western Digital Black SN850 2TB M.2-2280 SSD, 7000MB/s Read, 5100MB/s Write
(programs on one, project files on the other)
Graphics MSI GeForce RTX 3090 SUPRIM X 24GB OC GPU
ASUS ROG Thor 1200W Semi-Modular 80+ Platinum PSU 
Fractal Design Define 7 XL Dark TG Case with 3 Fans
Dell SE3223Q 31.5 Inch 4K UHD (3840x2160) Monitor, 60Hz, & an Acer 24" monitor.

At the moment my filming is done with a Samsung Galaxy S23 Ultra 5G & a GoPro Hero11 Black

I've been a Joiner/Carpenter for 40yrs, apprentice trained time served, I don't have an apprentice of my own so to share my knowledge I put videos on YouTube.

YouTube videos - https://www.youtube.com/c/Gidjoiner

 

jetdv wrote on 5/1/2025, 4:35 PM

What version of VEGAS are you running? This is for versions 5 - 13.

import Sony.Vegas;

For current versions you need:

import ScriptPortal.Vegas;

You also need to fully designate ScriptPortal.Vegas.Region as .Net also has a "Region".

Try this version simplified and converted to C#:

using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Drawing;
using System.Runtime;
using System.Xml;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;


        public void Main(Vegas vegas)
        {
            myVegas = vegas;

            //Find the selected event
            Track track = FindSelectedTrack();
            if (null == track)
            {
                MessageBox.Show("no selected track");
            }
            else
            {
                foreach (TrackEvent evnt in track.Events)
                {
                    ScriptPortal.Vegas.Region myRegion = new ScriptPortal.Vegas.Region(evnt.Start, evnt.Length, evnt.ActiveTake.Name);
                    myVegas.Project.Regions.Add(myRegion);
                }
            }
        }

        private Track FindSelectedTrack()
        {
            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.Selected)
                {
                    return myTrack;
                }
            }
            return null;
        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas, string scriptFile, XmlDocument scriptSettings, ScriptArgs args)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

 

Gid wrote on 5/1/2025, 5:35 PM

@jetdv VP22 (248). Perfect thankyou, much appreciated, I can use this & then the Batch Render - Regions script 👍

Vegas Pro 18 - 22
Vegas Pro/Post 19
Boris Continuum & Sapphire, 
Silhouette Standalone + Plugin, 
Mocha Pro Standalone + Plugin, 
Boris Optics,
NewBlue TotalFX
Desktop PC Microsoft Windows 10 Pro - 64-Bit
ASUS PRO WS WRX80E-SAGE SE WIFI AMD Motherboard
AMD Ryzen Threadripper PRO 3975WX 3.5GHz 32 Core
Corsair iCUE H150i RGB PRO XT 360mm All-in-One Liquid CPU Cooler
RAM 256GB ( 8x Micron 32GB (1x 32GB) 2666MHz DDR4 RAM )
2x Western Digital Black SN850 2TB M.2-2280 SSD, 7000MB/s Read, 5100MB/s Write
(programs on one, project files on the other)
Graphics MSI GeForce RTX 3090 SUPRIM X 24GB OC GPU
ASUS ROG Thor 1200W Semi-Modular 80+ Platinum PSU 
Fractal Design Define 7 XL Dark TG Case with 3 Fans
Dell SE3223Q 31.5 Inch 4K UHD (3840x2160) Monitor, 60Hz, & an Acer 24" monitor.

At the moment my filming is done with a Samsung Galaxy S23 Ultra 5G & a GoPro Hero11 Black

I've been a Joiner/Carpenter for 40yrs, apprentice trained time served, I don't have an apprentice of my own so to share my knowledge I put videos on YouTube.

YouTube videos - https://www.youtube.com/c/Gidjoiner