@jetdv @zzzzzz9125 hi guys.... need a little guidance from your genius mind here.
its very easy for you. but i couldn't make it even with the help of ChatGPT
so here what i need.
there will be a selected event.
when i will run this script it should first check is there any velocity env point exist before cursor position.
if no or yes but with value (100) normal then this script should add a point at cursor position at at value 0 (freeze).
if the last point is of value (0) normal. then it should add the cursor point point at value (100) normal.
i tried this with ChatGPT.
and i got this.
using System; using System.Collections.Generic; using System.Windows.Forms; using ScriptPortal.Vegas; public class EntryPoint { public void FromVegas(Vegas vegas) { FreezeLastFrame(vegas); } private void FreezeLastFrame(Vegas vegas) { List<TrackEvent> selectedEvents = GetSelectedEvents(vegas); if (selectedEvents == null || selectedEvents.Count == 0) { MessageBox.Show("No Event Selected.", "Upps!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Timecode cursorPosition = vegas.Transport.CursorPosition; foreach (Track myTrack in vegas.Project.Tracks) { if (myTrack.IsVideo()) { foreach (VideoEvent vEvent in myTrack.Events) { if (vEvent.Selected) { Envelope vEnv = CreateOrResetVelocityEnvelope(vEvent); // Check if there is a point before the cursor position EnvelopePoint lastPointBeforeCursor = GetLastPointBeforeCursor(vEnv, cursorPosition); // Add a freeze point or normal point at the cursor if (lastPointBeforeCursor == null || lastPointBeforeCursor.Y == 1.0) { // If there is no point or the last point is normal (1.0), add a freeze point (0.0) at the cursor AddVelocityPoint(vEnv, cursorPosition, 0.0); } else if (lastPointBeforeCursor.Y == 0.0) { // If the last point before the cursor is freeze (0.0), add a normal point (1.0) at the cursor AddVelocityPoint(vEnv, cursorPosition, 1.0); } } } } } } private List<TrackEvent> GetSelectedEvents(Vegas vegas) { List<TrackEvent> selectedEvents = new List<TrackEvent>(); foreach (Track track in vegas.Project.Tracks) { foreach (TrackEvent trackEvent in track.Events) { if (trackEvent.Selected) { selectedEvents.Add(trackEvent); } } } return selectedEvents; } private Envelope CreateOrResetVelocityEnvelope(VideoEvent vEvent) { Envelope vEnv = GetVelocityEnvelope(vEvent); if (vEnv == null) { vEnv = new Envelope(EnvelopeType.Velocity); vEvent.Envelopes.Add(vEnv); } return vEnv; } private Envelope GetVelocityEnvelope(VideoEvent vEvent) { foreach (Envelope env in vEvent.Envelopes) { if (env.Type == EnvelopeType.Velocity) { return env; } } return null; } private void AddVelocityPoint(Envelope vEnv, Timecode PointLoc, double PointSpeed) { EnvelopePoint existingPoint = vEnv.Points.GetPointAtX(PointLoc); if (existingPoint == null) { EnvelopePoint newPoint = new EnvelopePoint(PointLoc, PointSpeed); vEnv.Points.Add(newPoint); } else { existingPoint.Y = PointSpeed; } } private EnvelopePoint GetLastPointBeforeCursor(Envelope vEnv, Timecode cursorPosition) { EnvelopePoint lastPoint = null; foreach (EnvelopePoint point in vEnv.Points) { if (point.X < cursorPosition) { lastPoint = point; } else { break; // Since points are ordered, we can stop as soon as we pass the cursor position } } return lastPoint; } }
so need you guys suggestions. thankyou