Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Asperamanca on November 07, 2012, 07:18:29 pm

Title: How to edit attributes in script?
Post by: Asperamanca 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?
Title: Re: How to edit attributes in script?
Post by: qwerty 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.
Title: Re: How to edit attributes in script?
Post by: Asperamanca on November 07, 2012, 08:32:36 pm
Thanks! That was a bit misleading.
Title: Re: How to edit attributes in script?
Post by: Geert Bellekens 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