Author Topic: How to edit attributes in script?  (Read 2972 times)

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
How to edit attributes in script?
« on: November 07, 2012, 07:18:29 pm »
I have a script that will recursively perform a "search and replace" for all elements of a package. It currently replaces in names, notes and filenames.

Now I would like to extend the script so it also replaces in attributes and operations of classes. But how do I edit attributes of a class within a script?

The description of the "Attributes" collection in class says it's "Read-only". It also says to "use the AddNew and Delete functions to manage attributes", but that doesn't make much sense on a read-only collection. And I didn't find the corresponding methods on the "class element" level.

Any ideas?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to edit attributes in script?
« Reply #1 on: November 07, 2012, 08:31:08 pm »
The read-only means you can not alter the collection. But you can add/remove contents from the collection via methods of these collections. Well, I'd recommend my Scripting book :-)

q.

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Re: How to edit attributes in script?
« Reply #2 on: November 07, 2012, 08:32:36 pm »
Thanks! That was a bit misleading.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to edit attributes in script?
« Reply #3 on: November 07, 2012, 09:04:37 pm »
You have to read "Read-only" as in the property Element.Attributes is readonly.
That means you can only Get the property but not Set it.

But yes a bit misleading, it had me too in the beginning ::)

Geert