📝⚙️(Script) Duplicate an event to a new track.

m3lquixd wrote on 3/6/2023, 10:58 AM

It would be interesting to be able to select an event and have a button to duplicate that event for a track above.

Last changed by m3lquixd on 3/11/2023, 2:57 PM, changed a total of 1 times.

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 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

Comments

m3lquixd wrote on 3/6/2023, 11:09 AM

@jetdv In this case, if an event has been grouped with another event or even an audio event. It should only duplicate the selected event and not the events grouped with it. If I select both the video event and the audio event below it then yes both will be duplicated right above.

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 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 3/6/2023, 11:16 AM

Ok, test this one...
 

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;
            VideoTrack vTrack = null;
            AudioTrack aTrack = null;

            foreach(Track myTrack in myVegas.Project.Tracks)
            {
                foreach(TrackEvent evnt in myTrack.Events)
                {
                    if (evnt.Selected)
                    {
                        if (myTrack.IsAudio())
                        {
                            aTrack = new AudioTrack(myTrack.Index);
                            myVegas.Project.Tracks.Add(aTrack);
                            evnt.Copy(aTrack, evnt.Start);
                        }
                        else
                        {
                            vTrack = new VideoTrack(myTrack.Index);
                            myVegas.Project.Tracks.Add(vTrack);
                            evnt.Copy(vTrack, evnt.Start);
                        }
                        evnt.Selected = false;
                    }
                }
            }
        }
    }
}

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

 

m3lquixd wrote on 3/6/2023, 11:33 AM

@jetdv It works perfectly to duplicate just one event, however when dealing with 2 events on different tracks it didn't come out as I expected.


I would like when I duplicate the copies to be in the same order.

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 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

m3lquixd wrote on 3/6/2023, 3:21 PM

@jetdv it is possible?

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 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 3/6/2023, 5:59 PM

Actually, it behaves exactly as expected. In your first video, you showed it adding a track above the selected event and then the event was copied to that track. And you had multiple tracks above that track that the new track was below. That's exactly what this one is doing. If it sees a selected event, it adds a track above that track and then copies the event to that track. If there are multiple selected events on the same track, it will create multiple new tracks. If you have selected events on multiple tracks, in every case, there will be a new track added above the selected event and the event will be copied to that new track.

In fact, this behavior makes more sense than trying to combine all new tracks into a similar location. In your first example, the script behaves exactly as demonstrated. In your second example, you seem to want the new tracks added at the top so, no, the script does not do that.

rock-c wrote on 3/6/2023, 7:46 PM

@jetdv I've heard from friends that coding is a thing that needs lots of energy. I'm glad jetdv has written so much useful codes for free, but I also hope you take care of your health and have plenty of time to rest.

m3lquixd wrote on 3/7/2023, 6:05 AM

@rock-c I really admire his work.

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 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

m3lquixd wrote on 3/7/2023, 6:19 AM

@jetdv I understand, it really implies that in the second video I want something different from the first video. but no, only in the first video I showed an example with only one media in a track, and in the second video I showed it with two media in 2 tracks, but the behavior I want is the same as in the first video. I don't want the tracks to go to the top, in the second video it can be confused with that, because I forgot to put more tracks at the top.

In this video I show an example of why I would like it to be like this. For example, I can duplicate 1 composite element and move them around if I want. PS.: I don't want the script to group the track, I grouped it just to show it in this example.

I would like the behavior to be the same as when we duplicate a track, but only with the event I selected. The example below is perfect.

I don't know if this is possible, if not it's ok. Thanks for your effort, I really appreciate 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 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 3/7/2023, 7:21 AM

Let's see if I'm understanding correctly. For a second version, you want all new tracks added above the first selected event but descending downward as they are created?

jetdv wrote on 3/7/2023, 7:24 AM

@m3lquixd How about this one?
 

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;
            VideoTrack vTrack = null;
            AudioTrack aTrack = null;

            int trackIndexToAdd = -1;

            foreach(Track myTrack in myVegas.Project.Tracks)
            {
                foreach(TrackEvent evnt in myTrack.Events)
                {
                    if (evnt.Selected)
                    {
                        if (trackIndexToAdd < 0)
                        {
                            trackIndexToAdd = myTrack.Index;
                        }
                        else
                        {
                            trackIndexToAdd++;
                        }
                        if (myTrack.IsAudio())
                        {
                            aTrack = new AudioTrack(trackIndexToAdd);
                            myVegas.Project.Tracks.Add(aTrack);
                            evnt.Copy(aTrack, evnt.Start);
                        }
                        else
                        {
                            vTrack = new VideoTrack(trackIndexToAdd);
                            myVegas.Project.Tracks.Add(vTrack);
                            evnt.Copy(vTrack, evnt.Start);
                        }
                        evnt.Selected = false;
                    }
                }
            }
        }
    }
}

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

 

m3lquixd wrote on 3/7/2023, 7:51 AM

@jetdv Thank you very much! Nice work as always.

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 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

m3lquixd wrote on 3/11/2023, 2:59 PM

@vkmast Could you move this post to scripting?

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 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

vkmast wrote on 3/11/2023, 3:09 PM

@m3lquixd OK.

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

@jetdv Is it possible to make the new video track created be the same color as the track where the selected event is?

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 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 4/13/2023, 4:47 PM

It appears that answer is no.

ronfromkwonV2 wrote on 4/19/2023, 11:57 AM

It seems that the track colour is a read-only property.

jetdv wrote on 4/19/2023, 2:26 PM

It seems that the track colour is a read-only property.

@ronfromkwonV2 Actually, it's more complicated than that:

  1. Only a VIDEO track has the "TrackColor" option - I do not see that property on an audio track
  2. TrackColor appears to be read-only but you can go to TrackColor.A(BGR) and those are indicated as get/set
  3. Changing the get/set "AGBR" values does not change the track color
  4. Changing the track color does change the "AGBR" values
  5. That property is not mentioned in the API that I can find...
Former user wrote on 12/5/2023, 7:07 PM

@jetdv Love this thanks, I quite often duplicate events 👍

It works perfectly if the events are on separate tracks , I've tried it with 2, 3, 4, events 👍

But if the events are on the same track it crashes VP

I can live with this as I normally just duplicate a single event, so I'm just sharing 👍

jetdv wrote on 12/6/2023, 8:50 AM

@Former user, if you have multiple events on the same track, it's getting into an endless loop because of the new tracks being added and the new events were also selected so with two events selected, it's duplicating that second event over and over and over again. Try this version:
 

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;
            VideoTrack vTrack = null;
            AudioTrack aTrack = null;

            int trackIndexToAdd = -1;

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                foreach (TrackEvent evnt in myTrack.Events)
                {
                    if (evnt.Selected)
                    {
                        if (trackIndexToAdd < 0)
                        {
                            trackIndexToAdd = myTrack.Index;
                        }
                        else
                        {
                            trackIndexToAdd++;
                        }
                        if (myTrack.IsAudio())
                        {
                            aTrack = new AudioTrack(trackIndexToAdd);
                            myVegas.Project.Tracks.Add(aTrack);
                            TrackEvent aev = evnt.Copy(aTrack, evnt.Start);
                            aev.Selected = false;
                        }
                        else
                        {
                            vTrack = new VideoTrack(trackIndexToAdd);
                            myVegas.Project.Tracks.Add(vTrack);
                            TrackEvent vev = evnt.Copy(vTrack, evnt.Start);
                            vev.Selected = false;
                        }
                        evnt.Selected = false;
                        myVegas.UpdateUI();
                    }
                }
            }
        }
    }
}

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

 

m3lquixd wrote on 12/6/2023, 10:32 AM

@jetdv Could the 2 duplicated events be on the same track instead of different tracks?

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 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 12/6/2023, 10:52 AM
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;
            VideoTrack vTrack = null;
            AudioTrack aTrack = null;
            bool SameTrack = false;

            int trackIndexToAdd = -1;

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                SameTrack = false;
                foreach (TrackEvent evnt in myTrack.Events)
                {
                    if (!SameTrack)
                    {
                        if (trackIndexToAdd < 0)
                        {
                            trackIndexToAdd = myTrack.Index;
                        }
                        else
                        {
                            trackIndexToAdd++;
                        }
                    }
                    if (evnt.Selected)
                    {
                        if (myTrack.IsAudio())
                        {
                            if (!SameTrack)
                            {
                                aTrack = new AudioTrack(trackIndexToAdd);
                                myVegas.Project.Tracks.Add(aTrack);
                            }
                            TrackEvent aev = evnt.Copy(aTrack, evnt.Start);
                            aev.Selected = false;
                        }
                        else
                        {
                            if (!SameTrack)
                            {
                                vTrack = new VideoTrack(trackIndexToAdd);
                                myVegas.Project.Tracks.Add(vTrack);
                            }
                            TrackEvent vev = evnt.Copy(vTrack, evnt.Start);
                            vev.Selected = false;
                        }
                        SameTrack = true;
                        evnt.Selected = false;
                        myVegas.UpdateUI();
                    }
                }
            }
        }
    }
}

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

 

m3lquixd wrote on 12/6/2023, 11:38 AM

For me it was good, @Former user can use the other one if the result is better for him.

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 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

Former user wrote on 12/6/2023, 5:00 PM

@jetdv Thankyou, very much appreciated, that last one is the one 👍

@m3lquixd I've chosen the last one above,👍

 

 

m3lquixd wrote on 2/9/2024, 2:08 PM

@jetdv A problem is happening, when I run the script it is no longer positioning the copy on a track just above, it is moving it downwards.

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 3 3200G 3.60 GHz
RAM:
    32,0GB Dual-Channel DDR4 2666MHz
Motherboard:
    BIOSTAR Group B450MX-S (AM4)
Graphics:
    4095MB NVIDIA GeForce GTX 1650 (ZOTAC International)
Storage:
    465GB Seagate ST500DM002-1BD142 (SATA )
    238GB Lexar 256GB SSD (SATA (SSD))
  931GB KINGSTON SNV2S1000G (SATA-2 (SSD))