Visual Studio 2022, Vegas Pro 18.0
So I'm running the following code in a ""custom command" project.
public static void AdjustBoundsTo1080p(VideoEvent targetEvent) { if(targetEvent != null) { Debug.WriteLine("Target Event not null"); } if (targetEvent.VideoMotion.Keyframes != null) { Debug.WriteLine("keyframes not null"); } if (targetEvent.VideoMotion.Keyframes[0] != null) { Debug.WriteLine("keyframes 0 index not null"); } VideoMotionKeyframes currentKeyframes = targetEvent.VideoMotion.Keyframes; VideoMotionKeyframe newSingleFrame = currentKeyframes[0]; Debug.WriteLine("About to check count"); Debug.WriteLine("Frame count is " + currentKeyframes.Count); Debug.WriteLine("After count report"); Debug.WriteLine("Changing the bounds of " + targetEvent.MediaType.ToString()); Debug.WriteLine("video events starts at " + targetEvent.Start); VideoMotionBounds bounds = newSingleFrame.Bounds; if (bounds == null) { Debug.WriteLine("bounds is null"); } string debugOutput = "Before change\n"; debugOutput += "Upper Left: " + bounds.TopLeft.X + "," + bounds.TopLeft.Y + "\n"; debugOutput += "Upper Right: " + bounds.TopRight.X + "," + bounds.TopRight.Y + "\n"; debugOutput += "Bottom Left: " + bounds.BottomLeft.X + "," + bounds.BottomLeft.Y + "\n"; debugOutput += "Bottom Right: " + bounds.BottomRight.X + "," + bounds.BottomRight.Y + "\n"; Debug.WriteLine(debugOutput); bounds.TopRight.Y = 0; bounds.TopLeft.Y = 0; bounds.BottomRight.Y = 1080; bounds.BottomLeft.Y = 1080; bounds.TopRight.X = 1920; bounds.TopLeft.X = 0; bounds.BottomRight.X = 1920; bounds.BottomLeft.X = 0; Debug.WriteLine("About to set bounds"); currentKeyframes[0].Bounds = bounds; Debug.WriteLine("After to setting bounds"); }
and the output I get is
Target Event not null keyframes not null keyframes 0 index not null About to check count Frame count is 1 After count report Changing the bounds of Video video events starts at 00:00:56.04 Before change Upper Left: 320,180 Upper Right: 1600,180 Bottom Left: 320,900 Bottom Right: 1600,900 About to set bounds Exception thrown: 'System.ApplicationException' in ScriptPortal.Vegas.dll
I've also tried adding more keyframes but when I check the count it also throws an exception.
VideoMotionKeyframe nkf = new VideoMotionKeyframe(Timecode.FromSeconds(1)); currentKeyframes.Add(nkf); VideoMotionKeyframe nkf2 = new VideoMotionKeyframe(Timecode.FromSeconds(2)); currentKeyframes.Add(nkf2); // Exception just by checking the count Debug.WriteLine("Frame count is " + currentKeyframes.Count);
But here is the thing, when I go to my other project. The one that makes one off DLL's it works. I don't understand the difference between the projects. So in the end what I'm asking is there anything that I forgot to setup in a custom command project to explain this behavior?