Book a Demo

Author Topic: Addin: Read tagged values from Connector element  (Read 6367 times)

Marko Kaiser

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Addin: Read tagged values from Connector element
« on: March 03, 2011, 01:38:21 am »
I try to read a specific tagged value from a connector element in a c# addin.

Code: [Select]
EA.ConnectorTag tv = (EA.ConnectorTag)connector.TaggedValues.GetByName("someNiceName");

But at this point EA is throwing an error message box - Action not supported.  I use version 8.0.863 of EA.

Can anybody point me to the right direction?
« Last Edit: March 03, 2011, 01:46:51 am by MarkoK »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Addin: Read tagged values from Connector eleme
« Reply #1 on: March 03, 2011, 05:22:54 am »
I'm afraid GetByName is supported only for very few collections. See the help.

q.

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: Addin: Read tagged values from Connector eleme
« Reply #2 on: March 03, 2011, 06:30:11 am »
for that case i use my own methods

Code: [Select]
public static EA.ConnectorTag findTaggedValue(EA.Connector element, String name)
        {
            element.TaggedValues.Refresh();
            EA.ConnectorTag aTag = null;

            foreach (EA.ConnectorTag aTaggi in element.TaggedValues)
            {
                if (aTaggi.Name == name) aTag = aTaggi;
            }
            return aTag;
        }


or the sql version of the method which will directly returns the value of the taggedValue if there is one with this name.
Code: [Select]
public static String SearchTaggedValueSQL(EA.Repository Repository, EA.Connector actCon, String tagName)
        {
            
            String diagrams = Repository.SQLQuery("select t_connectortag.VALUE FROM t_connectortag where t_connectortag.Property = '"+tagName+"' and t_connectortag.ElementID = "+actCon.ConnectorID);
            MatchCollection diagrams_List = Regex.Matches(diagrams, "<VALUE>.*?</VALUE>");
            List<String> diagram_ids = new List<String>();
            foreach (Match id in diagrams_List)
            {
                String splitted = id.ToString(); ;
                splitted = splitted.Replace("<VALUE>","").Replace("</VALUE>","");
                return splitted;
            }
            return "";
        }

eaeio

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Addin: Read tagged values from Connector eleme
« Reply #3 on: March 03, 2011, 07:22:34 am »
are there any documentation on the use of SQL queries to get or set properties?

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: Addin: Read tagged values from Connector eleme
« Reply #4 on: March 03, 2011, 08:12:09 am »
unfortunately there are none (afaik)
but what you could do is to use the EA internal SQL Search to check the database and to find out which information you need and how to get it.

In EA open an .eap press STRG+f and switch to SQL tab.

select * from t_object
will get all information of alle elements in the .eap.
strg+space can be used.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Addin: Read tagged values from Connector eleme
« Reply #5 on: March 03, 2011, 09:28:41 pm »
I never asked why GetByName is limited to the current set of collections. Probably the GetByName is not inherited but implemented separately for each collection. Is there any class design for EA? At least it is missing in this region.

q.

Marko Kaiser

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Addin: Read tagged values from Connector eleme
« Reply #6 on: March 04, 2011, 01:59:11 am »
Thanks four your help. Code works like a charm.  ;)