How do you edit text within the script? C# Vegas 14

george-w wrote on 7/30/2020, 1:12 PM

I want to be able to specify what text I want within the script.

Is there a way to edit text without adding a preset?

Here is my code so far, I am only able to use a preset in it.

 

                PlugInNode generator = myVegas.Generators.GetChildByName("Sony Titles & Text");

                Media media = new Media(generator, "(Default)");

                MediaStream stream = media.Streams[0];

                VideoEvent newEvent = new VideoEvent(myVegas.Transport.CursorPosition, Timecode.FromSeconds(2));

                myVegas.Project.Tracks[0].Events.Add(newEvent);

                Take take = new Take(stream);

                newEvent.Takes.Add(take);

Comments

jetdv wrote on 7/30/2020, 4:38 PM

Ok, you've added the event to the track. Now you have to actually change the text. Try something like this:

            Effect gEffect = newEvent.ActiveTake.Media.Generator;
            OFXEffect fxo = gEffect.OFXEffect;

            //Change the Text
            OFXStringParameter tparm = (OFXStringParameter)fxo.FindParameterByName("Text");
            RichTextBox rtfText = new RichTextBox();
            //rtfText.Rtf = tparm.Value;  //this will get the text that is already in the box if you want to change the existing text
            rtfText.Text = "Whatever you want the text to read";

            //You can change the font too
            rtfText.SelectAll();
            rtfText.SelectionFont = QLFont;

            //Set the text!
            tparm.Value = rtfText.Rtf;

            fxo.AllParametersChanged();