Is there a way to get special character from text media in regions ?

playmarius wrote on 11/27/2021, 6:37 PM

using System;
using System.Text;
using System.Collections.Generic;
using System.Windows.Forms;
using ScriptPortal.Vegas;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        foreach (Track track in vegas.Project.Tracks)
        {
            // only the selected tracks
            if (!track.Selected) continue;
                        
            foreach (TrackEvent trackEvent in track.Events)
            {
                //This method works - but it does not show special characters
                
                string MiniActiveTakeName = trackEvent.ActiveTake.Name.Substring(20);
                
                //This method don't work !!
                
                // PlugInNode node = vegas.Generators;
                
                // Media media = media.Generator.OFXEffect;
                // OFXStringParameter txtparam = (OFXStringParameter) ofxEffect.FindParameterByName("Text");
                
                // string MiniActiveTakeName = txtparam.Value;

                Region region = new Region(trackEvent.Start, trackEvent.Length, MiniActiveTakeName);
                try
                {
                    vegas.Project.Regions.Add(region);
                    
                }
                catch (Exception e)
                {
                    MessageBox.Show(String.Format("Couldn't place Region at {0}\nThe error message: {1}", trackEvent.Start.ToString(), e.Message));
                }
            }
        }
    }
}

Hi, can anyone help me figure out a method to get text from a text media event and put it in region. With ActiveTake it does not show special character like " ș ț ". In other words the name of the region is "ăîâ??./" and it should be "ăîâșț./".

Comments

jetdv wrote on 11/28/2021, 7:48 AM

It appears to have worked for me:

As I didn't leave "Titles and Text" in the "Name", I changed this line:

string MiniActiveTakeName = trackEvent.ActiveTake.Name.Substring(20);

to:

string MiniActiveTakeName = trackEvent.ActiveTake.Name;

 

In your "Name" on the event, you can see yours says ??.

jetdv wrote on 11/28/2021, 7:59 AM

And pulling the text from the "Titles and Text" box appears to work fine too:

Here's the code that properly reads from the text box:
 

using System;
using System.Text;
using System.Collections.Generic;
using System.Windows.Forms;
using ScriptPortal.Vegas;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        foreach (Track track in vegas.Project.Tracks)
        {
            // only the selected tracks
            if (!track.Selected) continue;
                        
            foreach (TrackEvent trackEvent in track.Events)
            {
                
                Media media = trackEvent.ActiveTake.Media;
                OFXEffect ofxEffect= media.Generator.OFXEffect;
                OFXStringParameter txtparam = (OFXStringParameter) ofxEffect.FindParameterByName("Text");
                RichTextBox rtfText = new RichTextBox();
                rtfText.Rtf = txtparam.Value;
                
                string MiniActiveTakeName = rtfText.Text;

                Region region = new Region(trackEvent.Start, trackEvent.Length, MiniActiveTakeName);
                try
                {
                    vegas.Project.Regions.Add(region);
                    
                }
                catch (Exception e)
                {
                    MessageBox.Show(String.Format("Couldn't place Region at {0}\nThe error message: {1}", trackEvent.Start.ToString(), e.Message));
                }
            }
        }
    }
}

Compare my reading the text box code to yours to see the differences.

playmarius wrote on 11/28/2021, 10:17 AM

In your "Name" on the event, you can see yours says ??.

Yes i think that was the problem.

Thank you for the help now it works like a charm :)