Book a Demo

Author Topic: Can't read a tagged value in VB script  (Read 7860 times)

alexd

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
  • Headshot!
    • View Profile
Can't read a tagged value in VB script
« on: October 15, 2010, 02:19:56 am »
Hi all,
i have a some script, where I looking for every connection in current diagram for some named tagged value. And, here is a problem, because a scripter crash down with message "Action is not supported". Here is my sample code:

option explicit

Dim r as EA.Repository
Dim l as EA.DiagramLink
Dim d as EA.Diagram
Dim c as EA.Connector
Dim diagramid
Dim zpol

sub main
    diagramid = 0

    Set r = App.Repository

    if (diagramid = 0) then
        set d = r.GetCurrentDiagram()
        diagramid = d.DiagramID
    end if
    Set d = r.GetDiagramByID(diagramid)

    For each l in d.DiagramLinks
        Set c = r.GetConnectorByID(l.ConnectorID)
        set zpol = c.TaggedValues.GetByName("t_em_zavislost.c_zavislost")
        if not zpol is nothing then
            Session.Output zpol.Value
        else
            Session.Output "Nothing"
        end if
    Next
end sub

main

Error occurs on line set zpol = c.TaggedValues.GetByName("t_em_zavislost.c_zavislost").

For reproduce, U can create a new diagram, add 2 objects, connect objects with Dependency link and add a new tagged value "t_em_zavislost.c_zavislost" to link with value 0 (zero).

It is a bug or feature?   >:(:o
« Last Edit: October 15, 2010, 02:31:09 am by alexd »
What's this world coming to?

Luis J. Lobo

  • EA User
  • **
  • Posts: 252
  • Karma: +0/-0
  • IT Consultant
    • View Profile
Re: Can't read a tagged value in VB script
« Reply #1 on: October 15, 2010, 02:31:19 am »
I think it's a bug.

I had some problems accessing to connector's tagged values with the "GetByName" method. The "GetAt(x)" method works fine.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Can't read a tagged value in VB script
« Reply #2 on: October 15, 2010, 08:23:05 am »
The documentation says you can't use GetByName.

Quote
Only supported for the following collections: Model, Package, Element, Diagram, and element TaggedValue.

alexd

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
  • Headshot!
    • View Profile
Re: Can't read a tagged value in VB script
« Reply #3 on: October 15, 2010, 08:23:55 pm »
Quote
The documentation says you can't use GetByName.

Quote
Only supported for the following collections: Model, Package, Element, Diagram, and element TaggedValue.

Oops, you are right. This is curious. IMHO, collection is collection, but here like as collection is not collection. Hmmm ... thanx you Luis and Simon.

My original script is more complicated and using GetAt is dangerous, because index of appropriate item is not constant. I must find relevant index with loop ... for every connector ...  :'( ... So, live is hard  ;)
What's this world coming to?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Can't read a tagged value in VB script
« Reply #4 on: October 18, 2010, 04:17:53 pm »
Alex,

The reason you can't use GetByName is probably because the name isn't guaranteed to be unique.

Geert

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: Can't read a tagged value in VB script
« Reply #5 on: October 18, 2010, 07:52:07 pm »
The name isn't guaranteed go be unique with packages or elements either. The reason you can use GetByName for element tagged values but not for connector tagged values is probably nothing but bad architecture leading to inconsistency.

alexd

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
  • Headshot!
    • View Profile
Re: Can't read a tagged value in VB script
« Reply #6 on: October 21, 2010, 05:54:43 am »
Quote
The reason you can't use GetByName is probably because the name isn't guaranteed to be unique.
Hi Geert,
I am unhappy with the fact that the collection TaggedValues in the class Element behaves differently than the collection TaggedValues in class Connector. "Curiouser and curiouser" ;)
What's this world coming to?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Can't read a tagged value in VB script
« Reply #7 on: October 21, 2010, 04:13:06 pm »
Quote
I am unhappy with...

Then there's two of us ;)

Geert