Scripting Changes to OFX Parameters

MisterTik wrote on 12/1/2016, 11:49 AM

Using Vegas Pro V. 13 - Windows 10, Geforce GTX 750 Ti

Hello all!

I'm having a slight issue keeping changes to my OFX parameters using a script. My understanding (based mostly on the script here: https://www.vegascreativesoftware.info/us/forum/generated-media-customparameter-problem-for-titles--102387/ is that OFX parameters can be changed by using the OFXParameter object. Unfortunately, even with all my finagling, I still haven't figured out exactly HOW that's supposed to work, and I can't find any documentation on it aside from the API, which has been rather unhelpful on that front. Hopefully I'm just blind and someone can direct me to it. :)

The immediate goal is to simply make the script switch out the 'Titles and Text' Preset text with new text (the longterm goal is to switch out the preset text with Media Marker labels, which I could manage on my own once I figure this part out). This is the code for the script itself (it's messy and terrible, I've been finagling):
 

public class EntryPoint
{
    public void FromVegas (Vegas vegas)
    {
        Project proj = vegas.Project;
        VideoTrack titleTrack = new VideoTrack(proj, -1, "titleTrack");
        proj.Tracks.Add(titleTrack);

        Timecode start = new Timecode(0);
        Timecode end = new Timecode(1000);
        VideoEvent ve = new VideoEvent(proj, start, end, "ev");
        titleTrack.Events.Add(ve);
        PlugInNode plugIn = vegas.Generators.FindChildByUniqueID("{Svfx:com.sonycreativesoftware:titlesandtext}");
        String presetName = "Mister Tik";

        Media media = new Media(plugIn, presetName);
        OFXEffect ofxEffect = media.Generator.OFXEffect;
        OFXStringParameter textParam = ofxEffect.FindParameterByName("Text") as OFXStringParameter;
        XmlDocument textValDoc = new XmlDocument();
        MessageBox.Show(textParam.Value);
        textValDoc.LoadXml("<OfxParamValue>"+textParam.Value+"</OfxParamValue>");
        
        XmlNode textPValue = textValDoc.FirstChild;
        textPValue.InnerText= "{\\rtf1\\ansi\\ansicpg1252\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Verdana;}}\\viewkind4\\uc1\\pard\\lang1033\\f0\\fs96 Replaced\\par}";
        textParam.Value = textPValue.InnerText;
        MessageBox.Show(textParam.Value);
        textParam.ParameterChanged();
        
        Effect effect = new Effect(plugIn);
        ve.Effects.Add(ofxEffect);
        effect.Preset = presetName;
    }
}

And this is the code for the preset I added to the bottom of the PresetPackage.xml file:
 

<OfxPreset plugin="com.sonycreativesoftware:titlesandtext" context="Generator" name="Mister Tik">
        <OfxPlugin>com.sonycreativesoftware:titlesandtext</OfxPlugin>
        <OfxPluginVersion>1 0</OfxPluginVersion>
        <OfxParamTypeString name="Text">
            <OfxParamValue>{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Verdana;}}\viewkind4\uc1\pard\lang1033\f0\fs96 Test\par}
            </OfxParamValue>
        </OfxParamTypeString>
        <OfxParamTypeRGBA name="TextColor">
            <OfxParamValue>1.000000 1.000000 1.000000 1.000000</OfxParamValue>
        </OfxParamTypeRGBA>
        <OfxParamTypeString name="AnimationName">
            <OfxParamValue>Default</OfxParamValue>
        </OfxParamTypeString>
        <OfxParamTypeDouble name="Scale">
            <OfxParamValue>1.000000</OfxParamValue>
        </OfxParamTypeDouble>
        <OfxParamTypeDouble2D name="Location">
            <OfxParamValue>0.850000 0.900000</OfxParamValue>
        </OfxParamTypeDouble2D>
        <OfxParamTypeRGBA name="Background">
            <OfxParamValue>0.000000 0.000000 0.000000 0.000000</OfxParamValue>
        </OfxParamTypeRGBA>
        <OfxParamTypeDouble name="Tracking">
            <OfxParamValue>0.000000</OfxParamValue>
        </OfxParamTypeDouble>
        <OfxParamTypeDouble name="LineSpacing">
            <OfxParamValue>1.000000</OfxParamValue>
        </OfxParamTypeDouble>
        <OfxParamTypeDouble name="OutlineWidth">
            <OfxParamValue>0.000000</OfxParamValue>
        </OfxParamTypeDouble>
        <OfxParamTypeRGBA name="OutlineColor">
            <OfxParamValue>1.000000 1.000000 1.000000 1.000000</OfxParamValue>
        </OfxParamTypeRGBA>
        <OfxParamTypeBoolean name="ShadowEnable">
            <OfxParamValue>false</OfxParamValue>
        </OfxParamTypeBoolean>
        <OfxParamTypeRGBA name="ShadowColor">
            <OfxParamValue>0.000000 0.000000 0.000000 1.000000</OfxParamValue>
        </OfxParamTypeRGBA>
        <OfxParamTypeDouble name="ShadowOffsetX">
            <OfxParamValue>0.200000</OfxParamValue>
        </OfxParamTypeDouble>
        <OfxParamTypeDouble name="ShadowOffsetY">
            <OfxParamValue>0.200000</OfxParamValue>
        </OfxParamTypeDouble>
        <OfxParamTypeDouble name="ShadowBlur">
            <OfxParamValue>0.400000</OfxParamValue>
        </OfxParamTypeDouble>
    </OfxPreset>

I appreciate any help or direction! Thank you! :)

Comments

No comments yet - be the first to write a comment...