Create a script that removes transitions?

Thiago_Sase wrote on 8/3/2024, 3:58 PM

@jetdv @zzzzzz9125 Please, could you help me to create a script that removes transitions from selected events. I've tried a lot of ways, but nothing works.

 

Comments

jetdv wrote on 8/3/2024, 6:02 PM

@Thiago_Sase Basically, take the script that I wrote to FIND transitions and modify it to look at only selected events and then remove them. This is a quick update to that script but I have not tested it.

using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

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

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (VideoEvent vEvnt in myTrack.Events)
                    {
                        if (vEvnt.Selected)
                        {
                            RemoveAnyTransition(vEvnt.FadeIn);
                            RemoveAnyTransition(vEvnt.FadeOut);
                        }
                    }
                }
            }
        }

        public void RemoveAnyTransition(Fade fade)
        {
            object trans = fade.Transition;

            if (trans != null)
            {
                fade.RemoveTransition();
            }
        }
    }
}

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

 

Thiago_Sase wrote on 8/5/2024, 8:30 AM

@jetdv Thank you very much sir! It worked.

jetdv wrote on 8/5/2024, 8:42 PM

@Thiago_Sase, I later tested it and then created a tutorial based on it. It will be coming up in a few weeks.

Thiago_Sase wrote on 8/5/2024, 9:01 PM

@jetdv Very good news! Thank you.

Thiago_Sase wrote on 8/6/2024, 8:02 PM

@jetdv Please sir, if you can help, I watched these tutorials;

How to get the list of effects:
How to add an effect and pick a preset:
Add Generated Media to the timeline:

But, I can't make it work picking the preset of the Media Generator as the same as an effect.

When i use the script the Media generator (legacy text) is added in the timeline but the Preset is not.

 

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


namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;
        public void Main(Vegas vegas)
        {
            myVegas = vegas;

            Track myTrack = myVegas.Project.Tracks[0];

            string genUID = "{0FE8789D-0C47-442A-AFB0-0DAF97669317}";
            int presetCount = 3;
            PlugInNode plugIn = null;
            plugIn = myVegas.Generators.GetChildByUniqueID(genUID);

            Media media = new Media(plugIn);
            MediaStream stream = media.Streams.GetItemByMediaType(MediaType.Video, 0);
            VideoEvent newEvent = new VideoEvent(myVegas.Transport.CursorPosition, Timecode.FromSeconds(10));
            myTrack.Events.Add(newEvent);
            Take take = new Take(stream);
            newEvent.Takes.Add(take);

            Effect effect = new Effect(plugIn);
            newEvent.Effects.Add(effect);

            effect.Preset = effect.Presets[presetCount].Name;

        }

    }
}


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

The mistakes are in these lines?;

Effect effect = new Effect(plugIn);
            newEvent.Effects.Add(effect);

            effect.Preset = effect.Presets[presetCount].Name;

The script is about insert the media generator legacy text with the preset soft shadow or any other preset.

jetdv wrote on 8/6/2024, 8:12 PM

Try this:
 

            string genUID = "{Svfx:com.vegascreativesoftware:titlesandtext}"; //Magix Titles & Text
            int presetCount = 3;
            PlugInNode plugIn = null;
            plugIn = myVegas.Generators.GetChildByUniqueID(genUID);

            Media media = new Media(plugIn);
            MediaStream stream = media.Streams.GetItemByMediaType(MediaType.Video, 0);
            VideoEvent newEvent = new VideoEvent(myVegas.Transport.CursorPosition, Timecode.FromSeconds(15));
            Mtrack.Events.Add(newEvent);
            Take take = new Take(stream);
            newEvent.Takes.Add(take);

            Effect gEffect = newEvent.ActiveTake.Media.Generator;
            gEffect.Preset = gEffect.Presets[presetCount]

 

Thiago_Sase wrote on 8/6/2024, 8:34 PM

@jetdv This line;

  gEffect.Preset = gEffect.Presets[presetCount];

Gives the error: Cannot implicitly convert type 'ScriptPortal.Vegas.EffectPreset' to 'string'.

jetdv wrote on 8/7/2024, 8:01 AM

Sorry, left off the .Name...

            Effect gEffect = newEvent.ActiveTake.Media.Generator;
            gEffect.Preset = gEffect.Presets[presetCount].Name;

 

Thiago_Sase wrote on 8/7/2024, 8:11 AM

@jetdv It worked Sir. Thank you very much!