copying over picture in picture information

yugo-hughes wrote on 1/6/2025, 5:46 PM



im trying to make it easier for myself i have 2 scripts i am working on and i am not good at coding and i am running into error after error i wanted to be able to use a script to take the information from the earliest event on the timeline selected and then put that information onto the other selected events further ahead that are selected so bassically 1 would be giving the information to the others but i dont want to paste event attributes i want to only paste the events onto the other events that have picture in picture on them but only the first picture in picture on each even so all the events have 2 pip on them and i want to take the info from the first one and then paste it to the other ones but just on the first pip in the fx line sorry if what i am saying is confusing or doesnt make any sense but here is the script ive come up with so far
 

using System;
using System.Windows.Forms;
using ScriptPortal.Vegas;
using System.Collections.Generic;public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        CopyPIPSettings(vegas);
    }    public void CopyPIPSettings(Vegas vegas)
    {
       // Get the selected events
        var selectedEvents = new List<TrackEvent>();
        foreach (Track track in vegas.Project.Tracks)
        {
            foreach (TrackEvent evnt in track.Events)
            {
                if (evnt.Selected)
                {
                    selectedEvents.Add(evnt);
                }
            }
        }        if (selectedEvents.Count < 2)
        {
            MessageBox.Show("Select at least two events.", "Error");
            return;
        }        // Get the source PIP event
        TrackEvent sourceEvent = selectedEvents[0];        // Find all Picture in Picture effects on the source event
       List<Effect> sourcePIPs = new List<Effect>();       if(sourceEvent is VideoEvent)
       {
            foreach (Effect fx in ((VideoEvent)sourceEvent).Effects)
            {
                if (fx.PlugIn.Name == "Picture in Picture")
                {
                    sourcePIPs.Add(fx);
                }
            }
       }        if (sourcePIPs.Count == 0)
        {
            MessageBox.Show("The first selected event does not have a Picture in Picture effect.", "Error");
            return;
        }        // Apply the effect to the remaining events
        for (int i = 1; i < selectedEvents.Count; i++)
        {
             TrackEvent targetEvent = selectedEvents[i];            // Apply each of the PIP effects
            foreach(Effect sourcePIP in sourcePIPs){                 // Get the source PIP effect settings
                 var sourcePIPsettings = new Dictionary<string, object>();
                 if(sourcePIP.PlugIn.IsOFX)
                 {
                     foreach (OFXParameter prop in sourcePIP.OFXEffect.Parameters)
                     {
                       if(prop is OFXParameter<object, OFXKeyframe>) {
                           sourcePIPsettings[prop.Name] = ((OFXParameter<object, OFXKeyframe>)prop).Value;
                       }
                     }
                 }                Effect targetPIP = null;                if(targetEvent is VideoEvent)
                {
                    foreach (Effect fx in ((VideoEvent)targetEvent).Effects)
                     {
                        if (fx.PlugIn.Name == "Picture in Picture")
                         {
                           targetPIP = fx;
                           break;
                          }
                     }                  if (targetPIP == null)
                   {
                     targetPIP = ((VideoEvent)targetEvent).Effects.AddEffect(vegas.VideoFX.FindChildByName("Picture in Picture"));
                   }                      if(targetPIP.PlugIn.IsOFX) {
                            foreach (OFXParameter prop in targetPIP.OFXEffect.Parameters)
                            {
                               if (sourcePIPsettings.ContainsKey(prop.Name))
                               {
                                  if(prop is OFXParameter<object, OFXKeyframe>) {
                                     ((OFXParameter<object, OFXKeyframe>)prop).Value = sourcePIPsettings[prop.Name];
                                   }
                               }
                            }
                       }
                }             }
        }
        MessageBox.Show("Picture in Picture settings copied.", "Success");
    }
}

 

Comments

jetdv wrote on 1/7/2025, 10:04 AM

You do know you can just select the source event, press CTRL-C, now select the rest of the events, right-click and choose Paste Event Attributes and it will do that for you? Or right-click and choose "Selectively Past Event Attributes" if you don't want all attributes copies.

I will look over the code to see what's going on as well.

yugo-hughes wrote on 1/8/2025, 9:47 AM

i figgured it out i finished writing the code i dont need help with the subject anymore @jetdv also that would help it will paste a new fx when i want it to edit one of the fx already in the stack of fx i dont want to individually move the fx back into place but thank you for trying i am going to make a new post ive ran into a new problem with a different script i was working on i see you be helping out alot of ppl on here so i will try and give you credit for even attempting to help on my post!