Features, discussions, tips, tricks, questions, problems and feedback

Forum_Adroit/MAPS_SUI_Configuration - How to retrieve alias names and values from a script (c#)

Code snippet:

try
  {
     VIZNET.Spiders.Event.EventHashtablePropertySpider aliasSpider = MyController["Form.Aliases"] as VIZNET.Spiders.Event.EventHashtablePropertySpider;
     if (aliasSpider.OutputIOItems.Count == 0)
     {
        MessageBox.Show("No aliases defined");
     }
     else
     {
        //The name of the alias is in the entry.Key property; 
        //The value of the alias is in the DataElement.Value property;
        //We simply iterate through the InputIOItems and display them here:

        foreach (DictionaryEntry entry in aliasSpider.OutputIOItems)
        {
           IOItem item = entry.Value as IOItem;
           DataElement de = (item.Value == null) ? null : item.Value as DataElement;
           MessageBox.Show(entry.Key.ToString() + " :: " + ((de == null || de.Value == null) ? "EMPTY" : de.Value.ToString()));
        }
     }
  }
  catch (Exception ex)
  {
     MessageBox.Show("Oops. A problem occurred: " + ex.ToString());
  }
1 Like

Don’t forget to add the:

using VIZNET.Spiders.Event;
using VIZNET.UI.Runtime.SpiderController;

Hi. I have tried the above code and it works well inside a button event on a graphic form.
I have tried to add the code to the form_load event, but it seems that the alias values are not yet available when form_load event triggers. Is it because the Spider Engine is not yet ready when Form_Load event fires?

1 Like

Hi Marius,
You are right here, the aliases values are loaded after from_load. What You could do is to fetch the aliases based on some value changed event on control or maybe use script spider which would be silk triggered when alias output would be linked to it as script var 1 input.

1 Like

You will also need to include a reference to the following dll in your Script:

VIZNET.Spiders.EventHashtableProperty.dll