Discussion on 'SMART TRACK CONDENSE' Script's Obstacles.

iEmby wrote on 1/26/2026, 10:30 PM

SMART TRACK CONDENSE Script

1. Objective

To declutter the Vegas Pro project timeline by reducing the total number of tracks. The script must consolidate events from lower tracks onto upper tracks ("Merge Up"), ensuring absolutely zero change to the final Visual and Audio output.

2. Core Logic

Scope: The script must process both Video and Audio tracks.

Action: Move events from a lower track to an upper track while strictly maintaining their original Timecode.

Collision Detection: Before moving an event, the script must verify that the destination (target) track has empty space at that specific time duration. No overlaps are allowed.

3. Track Eligibility Conditions

A track can only be used as a "Source" (to take events from) or a "Target" (to put events onto) if it is considered "Clean."

A Track is defined as "Clean" only if:

No Track FX: The track has zero active plugins or effects.

Default Properties:

  • Video: Opacity is 100%.
  • Audio: Volume is 0dB (Unity Gain).
  • Compositing Mode: Set to default (Source Alpha). It must not be set to Screen, Multiply, Add, etc.
  • State: The track is NOT Muted and NOT Soloed.
  • Hierarchy: The track is a standard track (Level 0). It is neither a Parent nor a Child in a composite group.

4. Special Barrier Logic (Crucial for Rendering Integrity)

To prevent breaking the project's visual hierarchy, the following items act as "Barriers." Events cannot be moved across these barriers.

A. Adjustment Tracks & Events

If a track contains an Adjustment Event or is technically an Adjustment Track, it is treated as a hard barrier.

Rule: Events situated below an Adjustment Track must never be moved to a track above that Adjustment Track. Doing so would remove the effect of the adjustment layer from that event.

B. Parent/Child Groups

Any track involved in a Parent/Child relationship is Frozen.

The script must skip these tracks entirely to preserve the compositing structure.

5. Technical Summary (Algorithm Flow)

Logic:

Iterate: Scan tracks from Bottom to Top.

Zone Detection: Identify safe "Zones" separated by Barriers (Barriers = Tracks with FX, Parent/Child status, or Adjustment Events).

Process within Zone:

Select an Event on the lowest track within the current zone.

Scan upward within the same zone to find the highest possible track with empty space at the Event's timecode.

Action: If a valid spot is found, move the Event to that track.Cleanup: If a source track becomes completely empty after the process, delete the track.

------------------------------------

Hello everyone,
Specially hello to @zzzzzz9125 and @jetdv 👋

I just want to confirm one thing:
Is it possible to create this script with 100% functionality?

The reason I’m asking is because every time I need to minimize my project, it wastes 10–15 irritating minutes, and honestly, that’s killing productivity.

So before investing more time into this, I’d really appreciate your honest opinion on whether this is fully achievable or not.

Thanks in advance.

Last changed by iEmby

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

Some useful creations by me including VEGAS Scripts

https://getopensofts.blogspot.com/

 

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

Comments

iEmby wrote on 1/27/2026, 12:08 AM

Ok i have just finished creating this via help of ChatGPT.

From my side its all perfectly working.

please if you have some spare time. please test it on your behalf.

thankyou in advance.

using ScriptPortal.Vegas;
using System;
using System.Collections.Generic;

public class EntryPoint
{
    private Vegas vegas;

    public void FromVegas(Vegas v)
    {
        vegas = v;
        Condense();
    }

    private void Condense()
    {
        Tracks tracks = vegas.Project.Tracks;

        int i = tracks.Count - 1;
        while (i > 0)
        {
            // Adjustment track = HARD barrier
            if (IsAdjustmentBarrier(tracks[i]))
            {
                i--;
                continue;
            }

            int zoneEnd = i;
            int zoneStart = i;

            while (zoneStart > 0 && !IsAdjustmentBarrier(tracks[zoneStart - 1]))
                zoneStart--;

            ProcessZone(zoneStart, zoneEnd);
            i = zoneStart - 1;
        }
    }

    private void ProcessZone(int start, int end)
    {
        Tracks tracks = vegas.Project.Tracks;

        for (int i = end; i > start; i--)
        {
            Track source = tracks[i];
            if (!IsClean(source))
                continue;

            Track target = FindUpperCleanTrack(i - 1, start);
            if (target == null)
                continue;

            List<TrackEvent> moveList = new List<TrackEvent>();

            foreach (TrackEvent ev in source.Events)
            {
                // 🔒 FINAL GLOBAL RULE:
                // if ANY overlap exists ABOVE SOURCE → NO MOVE
                if (HasOverlapAboveSource(ev, source))
                    continue;

                // normal target overlap check
                if (HasOverlap(target, ev))
                    continue;

                moveList.Add(ev);
            }

            foreach (TrackEvent ev in moveList)
            {
                ev.Track = target;
            }

            if (source.Events.Count == 0)
                vegas.Project.Tracks.Remove(source);
        }
    }

    // 🔎 find nearest clean track above (FX skipped)
    private Track FindUpperCleanTrack(int fromIndex, int zoneStart)
    {
        Tracks tracks = vegas.Project.Tracks;

        for (int i = fromIndex; i >= zoneStart; i--)
        {
            Track t = tracks[i];

            if (IsAdjustmentBarrier(t))
                return null;

            if (IsClean(t))
                return t;
        }

        return null;
    }

    // 🔴 Adjustment track = hard wall
    private bool IsAdjustmentBarrier(Track t)
    {
        VideoTrack vt = t as VideoTrack;
        return (vt != null && vt.IsAdjustmentTrack);
    }

    // 🟢 clean track
    private bool IsClean(Track t)
    {
        if (t.Mute || t.Solo)
            return false;

        if (t.Effects.Count > 0)
            return false;

        VideoTrack vt = t as VideoTrack;
        if (vt != null)
        {
            if (vt.IsAdjustmentTrack)
                return false;

            if (vt.IsCompositingParent || vt.IsCompositingChild)
                return false;

            if (Math.Abs(vt.CompositeLevel - 1.0f) > 0.0001f)
                return false;

            if (vt.CompositeMode != CompositeMode.SrcAlpha)
                return false;
        }

        AudioTrack at = t as AudioTrack;
        if (at != null)
        {
            if (Math.Abs(at.Volume - 1.0) > 0.0001)
                return false;
        }

        return true;
    }

    // ❌ overlap on target
    private bool HasOverlap(Track target, TrackEvent ev)
    {
        foreach (TrackEvent te in target.Events)
        {
            if (te.Start < ev.End && ev.Start < te.End)
                return true;
        }
        return false;
    }

    // 🔒 FINAL KEY FUNCTION
    // checks ALL tracks ABOVE SOURCE (FX / clean / anything)
    private bool HasOverlapAboveSource(TrackEvent ev, Track source)
    {
        Tracks tracks = vegas.Project.Tracks;
        int sourceIndex = tracks.IndexOf(source);

        for (int i = sourceIndex - 1; i >= 0; i--)
        {
            foreach (TrackEvent te in tracks[i].Events)
            {
                if (te.Start < ev.End && ev.Start < te.End)
                    return true; // ❌ BLOCK ALWAYS
            }
        }

        return false;
    }
}

 

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

Some useful creations by me including VEGAS Scripts

https://getopensofts.blogspot.com/

 

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)