Changing interpolation of OFXDoubleParameter keyframe

wawak wrote on 10/29/2023, 5:31 PM

Hi guys, i'm writing a Vegas script using JetDV's tutorials that adds double value keyframes to an OFX effect on a video event (and it is working fine).

However, i'm now trying to change the interpolation setting of each of my keyframes from "linear" to "smooth" and i'm a bit lost since in the API documentation it doesn't seem to be possible because the "OFXInterpolationType" class referenced in the "OFXKeyframe" class doesn't seem to exist (the hyperlink links to nothing).

Does someone knows if it is possible and if I missed something ?

Thanks in advance.



jetdv wrote on 10/29/2023, 7:34 PM
OFXDoubleParameter p2 = (OFXDoubleParameter)ofx[Parameter];
double oc = ChildDouble(child, "Value");
p2.SetValueAtTime(tc, oc);
p2.Keyframes[i].Interpolation =  OFXInterpolationType.Sharp;

Or any of these other values:



Here's the entire section where I used the above:

                case "Double":
                        OFXDoubleParameter p2 = (OFXDoubleParameter)ofx[Parameter];
                        if (KeyframeCount == 0)
                            p2.Value = ChildDouble(elt, "Value");
                            p2.IsAnimated = true;
                            int i = 0;
                            foreach (XmlElement child in elt["Keyframes"])
                                Timecode tc = ChildTimecode(child, "Time");
                                if (isTrack) tc = QuantizeTC(tc + leftOffset);
                                double oc = ChildDouble(child, "Value");
                                p2.SetValueAtTime(tc, oc);
                                p2.Keyframes[i].Interpolation = ParseOFXCurveType(ChildString(child, "Interpolation"));
        private static OFXInterpolationType ParseOFXCurveType(String val)
            switch (val)
                case "Sharp":
                    return OFXInterpolationType.Sharp;
                case "Slow":
                    return OFXInterpolationType.Slow;
                case "Linear":
                    return OFXInterpolationType.Linear;
                case "Fast":
                    return OFXInterpolationType.Fast;
                case "Smooth":
                    return OFXInterpolationType.Smooth;
                case "Hold":
                    return OFXInterpolationType.Hold;
                case "Manual":
                    return OFXInterpolationType.Manual;
                case "Split":
                    return OFXInterpolationType.Split;
                    throw new ApplicationException("Unknown CurveType: " + val);


wawak wrote on 10/30/2023, 4:21 AM

Thanks for your answer, I tried iterating through my Keyframes using your code however it doesn't seem to work :


                 OFXDoubleParameter myAngle = (OFXDoubleParameter)ofx["Angle"];
                        for(int i = 0 ; i == myAngle.Keyframes.Count ; i++ ){
                              myAngle.Keyframes[i].Interpolation = OFXInterpolationType.Smooth;

When i check the keyframes placed in my OFX they are still interpolated as "linear"

The full code i'm using :


using System.Windows.Forms;
using ScriptPortal.Vegas;
using System;

public class EntryPoint

    Vegas myVegas;

    public void setOFXDoubleParameter(OFXEffect ofx, string ofxName, Timecode keyTime, double keyValue){
        OFXDoubleParameter ofxParam = (OFXDoubleParameter)ofx[ofxName];

        ofxParam.IsAnimated = true;
        ofxParam.SetValueAtTime(keyTime, keyValue);


    public void FromVegas(Vegas vegas){

        myVegas = vegas;

        string pluginID = "{Svfx:com.vegascreativesoftware:pictureinpicture}";
        PlugInNode fx = myVegas.VideoFX;
        PlugInNode plugin = fx.GetChildByUniqueID(pluginID);

        Effect effect = new Effect(plugin);

        foreach (Track myTrack in myVegas.Project.Tracks)

                foreach(TrackEvent evnt in myTrack.Events){

                    if (evnt.Selected){

                        VideoEvent vevnt = (VideoEvent)evnt;


                        double totalLength = evnt.Length.ToMilliseconds();

                            OFXEffect ofx = effect.OFXEffect;

                            Random rand = new Random();
                            double minValue = -2.0;
                            double maxValue = 2.0;

                            for(double ms = 0 ; ms < totalLength ; ms+=550){
                                double angle = rand.NextDouble() * (maxValue - minValue) + minValue;
                                setOFXDoubleParameter(ofx, "Angle", Timecode.FromMilliseconds(ms), angle);

                            OFXDoubleParameter myAngle = (OFXDoubleParameter)ofx["Angle"];
                            for(int i = 0 ; i == myAngle.Keyframes.Count ; i++ ){
                                myAngle.Keyframes[i].Interpolation = OFXInterpolationType.Smooth;







The result i get Vs The result i would like to have :

wawak wrote on 10/30/2023, 4:27 AM

I tried with a foreach and it seems to work now, thanks for your help !

foreach(OFXDoubleKeyframe elemnt in myAngle.Keyframes){
                                elemnt.Interpolation = OFXInterpolationType.Smooth;


jetdv wrote on 10/30/2023, 8:07 AM

I do believe either method should work but glad you got it working.