⚠️ (BUG?) New track with CTRL + SHIFT + Q

Comments

Former user wrote on 12/3/2023, 4:01 PM

@jetdv Thankyou 👍 I thought I'd tried that, maybe i was messing with Vegas's head but it worked now, maybe I didn't try that 🤦‍♂️

 

m3lquixd wrote on 12/12/2023, 5:56 PM

@jetdv I just realized something, I believe that the script should create the same number of tracks according to how many tracks are selected, for example: if there are two video tracks selected then two more new video tracks will be created

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 7 5700G 3.80 GHz
RAM:
    32,0GB Dual-Channel DDR4 3200MHz
Motherboard:
    ASRock B450M Steel Legend (AM4)
Graphics:
    MSI RTX 4060 Ventus 2X Black OC 8GB
Storage:
    476GB ADATA SU650 (SATA (SSD))
    931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 12/12/2023, 9:17 PM

@m3lquixd try changing (not tested!):

                if (myTrack.Selected && myTrack.IsVideo() && !FoundVideo)
                {
                    FoundVideo = true;
                    VideoTrack newVTrack = new VideoTrack(myTrack.Index);
                    myVegas.Project.Tracks.Add(newVTrack);
                }
                if (myTrack.Selected && myTrack.IsAudio() && !FoundAudio)
                {
                    FoundAudio = true;
                    AudioTrack newATrack = new AudioTrack(myTrack.Index + 1);
                    myVegas.Project.Tracks.Add(newATrack);
                }
                if (FoundAudio && FoundVideo)
                {
                    break;
                }

To:

                if (myTrack.Selected && myTrack.IsVideo())
                {
                    FoundVideo = true;
                    VideoTrack newVTrack = new VideoTrack(myTrack.Index);
                    myVegas.Project.Tracks.Add(newVTrack);
                }
                if (myTrack.Selected && myTrack.IsAudio())
                {
                    FoundAudio = true;
                    AudioTrack newATrack = new AudioTrack(myTrack.Index + 1);
                    myVegas.Project.Tracks.Add(newATrack);
                }
                myTrack.Selected = false;

 

m3lquixd wrote on 12/13/2023, 12:10 PM

@jetdv it is creating multiple tracks, but it only selects one, and not all the new tracks that were created at once

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;

            bool FoundVideo = false;
            bool FoundAudio = false;

            VideoTrack newVTrack = null;
            AudioTrack newATrack = null;

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.Selected && myTrack.IsVideo())
                {
                    FoundVideo = true;
                    newVTrack = new VideoTrack(myTrack.Index);
                    myVegas.Project.Tracks.Add(newVTrack);
                }
                if (myTrack.Selected && myTrack.IsAudio())
                {
                    FoundAudio = true;
                    newATrack = new AudioTrack(myTrack.Index + 1);
                    myVegas.Project.Tracks.Add(newATrack); 
                } 
                myTrack.Selected = false;
            }

            if (!FoundAudio && !FoundVideo)
            {
                newVTrack = new VideoTrack(0);
                myVegas.Project.Tracks.Add(newVTrack);


                newATrack = new AudioTrack(myVegas.Project.Tracks.Count);
                myVegas.Project.Tracks.Add(newATrack);
            }

            if (newVTrack != null)
            {
                newVTrack.Selected = true;
            }
            if (newATrack != null)
            {
                newATrack.Selected = true;
            }

        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

 

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 7 5700G 3.80 GHz
RAM:
    32,0GB Dual-Channel DDR4 3200MHz
Motherboard:
    ASRock B450M Steel Legend (AM4)
Graphics:
    MSI RTX 4060 Ventus 2X Black OC 8GB
Storage:
    476GB ADATA SU650 (SATA (SSD))
    931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 12/13/2023, 12:38 PM

Technically, with the last section there:

            if (newVTrack != null)
            {
                newVTrack.Selected = true;
            }
            if (newATrack != null)
            {
                newATrack.Selected = true;
            }

It should be selecting two tracks if both a video and audio were added. However, I'd go ahead and just remove that section too and let it select nothing.

Here's the reasoning behind that. If you go through a loop and add new tracks ABOVE the current track, the current track will then be processed again as the NEXT track. So if it's selected and remains selected, you'll get into an endless loop of it adding tracks for that one track. That's why I deselected it.

Also, if you added a new track AFTER the current track and you selected it, then it's now selected so another new track would be added after that track which, if you selected it... another endless loop.

So the SAFE option is simply deselecting all tracks as you go along.

Can it be done without deselecting? Yes but the code will become much longer because now you'll need to read in and store all of the tracks, go through them adding the proper tracks which becomes even more complicated because as you add tracks, the track indexes change so you really have to make sure the new tracks get added in the proper locations. Going through the stored list backwards should work to get them in the right place but you have to be very careful when adding tracks (or events or anything else you're looping through while adding) so that you don't end up with an endless loop which would force you to kill VEGAS to get out.

m3lquixd wrote on 12/13/2023, 1:51 PM

ok i got it

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 7 5700G 3.80 GHz
RAM:
    32,0GB Dual-Channel DDR4 3200MHz
Motherboard:
    ASRock B450M Steel Legend (AM4)
Graphics:
    MSI RTX 4060 Ventus 2X Black OC 8GB
Storage:
    476GB ADATA SU650 (SATA (SSD))
    931GB KINGSTON SNV2S1000G (SATA-2 (SSD))