Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums VEGAS Pro How to generate text in scripting?

  • How to generate text in scripting?

     Austin Brock updated 7 years, 9 months ago 2 Members · 7 Posts
  • Austin Brock

    October 2, 2013 at 4:43 pm

    I have this example code to “insert text media” using scripting…

    PlugInNode generator = app.Generators.GetChildByName("Sony Text");
    media = new Media(generator, "Footy Scores");
    stream = media.Streams[0];
    newEvent = new VideoEvent(evnt.Start, evLen);
    titleTrack.Events.Add(newEvent);
    take = new Take(stream);
    newEvent.Takes.Add(take);

    … but the code implies I have to use presets to determine what is written, and that I don’t have any control over it otherwise.

    Is this true, or is there another way?

  • Edward Troxel

    October 2, 2013 at 6:28 pm

    With the DirectX plugins, you can only set a preset. With the OpenFX plugins (i.e. Sony Titles & Text for example), you can set the text separately.

    Edward Troxel

  • Austin Brock

    October 2, 2013 at 6:28 pm

    Could you possibly give some examples of the OpenFX plugins, please?

  • Edward Troxel

    October 3, 2013 at 5:27 pm

    As I mentioned, Sony Titles & Text is an OpenFX titler. The only other OpenFX titler I know is NewBlue Titler Pro.

    Edward Troxel

  • Austin Brock

    October 3, 2013 at 5:31 pm

    My request was for example code for using “Sony Titles & Text” and customizing the text used.

  • Edward Troxel

    October 8, 2013 at 8:26 pm

    Basically, you’d do something like this:

    OFXStringParameter tparm = (OFXStringParameter)gEffect.OFXEffect.FindParameterByName(“Text”);

    rtfSwapText.Rtf = tparm.Value;
    rtfSwapText.Text = ReplaceText;
    tparm.Value = rtfSwapText.Rtf;

    Edward Troxel

  • Austin Brock

    December 31, 2013 at 10:15 pm

    If anyone wonders how I did this eventually, I made the format of the text I required in Sony Vegas, and then wrote C# to recreate the file I was using, like a temp.xml, and just overwrote it before using.

    Then I insert that media, and viola, it displays the correct text.

    // List of White Scorers
    generatorb = app.Generators.GetChildByName("Sony Titles & Text");
    CreateWhiteList(WhiteScoreString);
    mediad = new Media(generatorb, "EndScoresWhite");

    streamd = mediad.Streams[0];
    newEventd = new VideoEvent(endDisplay, endDisplayFor);
    app.Project.Tracks[2].Events.Add(newEventd);
    taked = new Take(streamd);
    newEventd.Takes.Add(taked);

    public int CreateWhiteList(string str)
    {
    string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "OFX Presetscom.sonycreativesoftware_titlesandtextGenerator" + "endscoreswhite.xml";

    if (File.Exists(path))
    File.Delete(path);

    using (StreamWriter sw = File.AppendText(path))
    {
    sw.WriteLine("<?xml version="1.0" encoding="UTF-8"?>");
    sw.WriteLine("");
    sw.WriteLine("com.sonycreativesoftware:titlesandtext");
    sw.WriteLine("1 0");
    sw.WriteLine(" {rtf1ansiansicpg1252deff0{fonttbl{f0fnilfcharset0 Interstate;}}");
    sw.WriteLine("viewkind4uc1pardlang1033bf0fs13 " + str);
    sw.WriteLine("}");
    sw.WriteLine("");
    sw.WriteLine("");
    sw.WriteLine("0.952941 0.952941 0.952941 1.000000");
    sw.WriteLine(" _None");
    sw.WriteLine("");
    sw.WriteLine("1.000000");
    sw.WriteLine("0.533000 0.220000");
    sw.WriteLine("0");
    sw.WriteLine("0.000000 0.000000 0.000000 0.000000");
    sw.WriteLine("0.000000");
    sw.WriteLine("1.000000");
    sw.WriteLine("7.500000");
    sw.WriteLine("0.000000 0.000000 0.000000 1.000000");
    sw.WriteLine("false");
    sw.WriteLine("0.000000 0.000000 0.000000 1.000000");
    sw.WriteLine("0.200000");
    sw.WriteLine("0.200000");
    sw.WriteLine("0.400000");
    sw.WriteLine("");
    }
    return 1;
    }

Viewing 1 - 7 of 7 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy