A script that add Fade in Trasition at cursor position

Thiago_Sase wrote on 7/18/2024, 10:05 AM

@jetdv Please, if possible, how i add the creation of a fade in trasition at cursor position in the code bellow?

 

using System;
using ScriptPortal.Vegas;

 
public class EntryPoint
{
  Vegas myVegas;

 

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

 

    foreach (Track track in myVegas.Project.Tracks)
    {
        foreach (TrackEvent trackEvent in track.Events)
        {
            if (trackEvent.Selected)
            {
               
                trackEvent.FadeIn.Length = new Timecode(1000);
            }
        }
    }
  }
}

Is this line i need to modify?

if (trackEvent.Selected)
            {
               
                trackEvent.FadeIn.Length = new Timecode(1000);
            }

 

Comments

jetdv wrote on 7/18/2024, 10:24 AM

Yes, that's the line you need to modify. Instead of "new Timecode(1000)", you'll need the cursor position minus the start of the event - assuming the cursor is inside of the event!

            if (trackEvent.Selected)
            {
                Timecode cursor = myVegas.Transport.CursorPosition;

                if (trackEvent.Start < cursor && trackEvent.End > cursor)
                {
                    trackEvent.FadeIn.Length = cursor - trackEvent.Start;
                }
            }

 

Thiago_Sase wrote on 7/18/2024, 10:39 AM

@jetdv Thank you. It worked.

Thiago_Sase wrote on 7/18/2024, 11:23 AM

@jetdv If is Fadeout, where is my mistake sir?

 if (trackEvent.Selected)
            {
                Timecode cursor = myVegas.Transport.CursorPosition;

                if (trackEvent.Start < cursor && trackEvent.End > cursor)
                {
                    trackEvent.FadeOut.Length = cursor - trackEvent.Start;
                }
            }

 

jetdv wrote on 7/18/2024, 11:26 AM
trackEvent.FadeOut.Length = trackEvent.End - cursor;

 

Thiago_Sase wrote on 7/18/2024, 11:33 AM

@jetdv Thank you.