Book a Demo

Author Topic: Maybe weird problems with "TaggedValues.GetByName(...)"  (Read 6192 times)

Shounbourgh

  • EA Novice
  • *
  • Posts: 18
  • Karma: +1/-0
    • View Profile
Maybe weird problems with "TaggedValues.GetByName(...)"
« on: May 28, 2016, 12:22:18 am »
Hi,
just a quick question.

Because the following vb-script snippet is NOT working for me (Error: Object requiered: "bitv"):
Code: [Select]
dim bitv as EA.TaggedValue
set bitv = element.TaggedValues.GetByName("BuiltInType")
bitv.Value = refBuiltIn.ElementGUID
bitv.Update()

i do it in the other way which is working:
Code: [Select]
for each tv in element.TaggedValues
if (tv.Name="BuiltInType") then
tv.Value = refBuiltIn.ElementGUID
tv.Update()
end if
next

Just wondering why the first snippet is not working ^^
Happy weekend.

Erik

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Maybe weird problems with "TaggedValues.GetByName(...)"
« Reply #1 on: May 28, 2016, 01:42:46 am »
Erik,

The GetByName only works on certain EA.Collections, and not on other.

I made it a habit of never using it and just looping the collection myself (which is probably what happens behind the scenes anyway)

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Maybe weird problems with "TaggedValues.GetByName(...)"
« Reply #2 on: May 28, 2016, 01:50:52 am »
Or you write your own wrapper. Tagged values may appear more than once with the same name which is why EA does not provide the GetByName here.

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Maybe weird problems with "TaggedValues.GetByName(...)"
« Reply #3 on: May 30, 2016, 08:54:42 pm »
According to the documentation, it should work for element tagged value collections. So it is a little weird.

Maybe you need to send in a fully-qualified name rather than a simple name?

/Uffe
My theories are always correct, just apply them to the right reality.