Change property of multiple elements at one time

2,119 views
Skip to first unread message

walx

unread,
Jul 28, 2011, 9:08:00 AM7/28/11
to sparx-enterprise-archite...@googlegroups.com
Hello,

I have several classes in my model. All of them have the property "Status" with the value "Proposal".

Is there a way to select all of them and change the value of the property at one time? Currently I can change the property only one by one.

Thanks
Walter

[original message]

RoyC

unread,
Jul 29, 2011, 8:05:00 AM7/29/11
to sparx-enterprise-archite...@googlegroups.com
Try looking for Update    Element Status, For Package  in the Help index; does that do what you want?
[original message]

walx

unread,
Jul 29, 2011, 3:27:00 AM7/29/11
to sparx-enterprise-archite...@googlegroups.com
Hello Roy,

yes, this function helps me for the moment. I could set all status properties. Thanks.

But what I expected, was something like:
1. Run a Model Search to select specific elements
2. Select a bunch of found elements from the search result
3. Change any property of the elements in Property tool window

or
1. Select a bunch of elements in a diagram
2. Change any property of the elements in Property tool window

Does EA support such a workflow?


[original message]

qwerty

unread,
Jul 29, 2011, 3:39:00 AM7/29/11
to sparx-enterprise-archite...@googlegroups.com
Welcome to the object oriented world. But not for EA users. Search the forum for "multiple selection" to get your daily portion of frustration.

q.

[original message]

Evgeny Sandu

unread,
Dec 15, 2016, 10:07:17 AM12/15/16
to Sparx Enterprise Architect General, sparx-enterprise-archite...@googlegroups.com, walx@localhost
There is a way I found here somewhere: scripts. You create a new Jscript like the one I have pasted below, then you select some elements in the object browser, right click→run this script, enter new value for the property you need to update. The property is hardcoded into the script, and in this example it's the Author field. I'd love it if anybody would enhance it somehow... 

!INC Local Scripts.EAConstants-JScript
!INC EAScriptLib.JScript-Dialog

 
function OnProjectBrowserScript()
{
// Get the type of element selected in the Project Browser
     var selElem as EA.Collection;

     var wart=DLGInputBox( 'New Author', 'Multi-select element update', '');
     
     selElem = Repository.GetTreeSelectedElements();
     for (i=0; i < selElem.Count; i++) {
           var e as EA.Element;
           e = selElem.GetAt(i);
           Session.Output('Element changed:'+e.Name);
           e.Author = wart;
           e.Update();
           e.Refresh();
     }
}

OnProjectBrowserScript();




пятница, 29 июля 2011 г., 10:27:00 UTC+3 пользователь walx написал:

Z L

unread,
Aug 6, 2020, 3:36:41 AM8/6/20
to Sparx Enterprise Architect General
Allow me to resurrect this thread :-)

As a newbie, I welcome all updates you guys found out by now..
I have a big list of elements that should be adapted to Validated, and the script looks perfect > before I start creating something myself or doing this manually.. Looking forward to your reply.

Thank you!
Z

Evgeny Sandu

unread,
Aug 9, 2020, 5:28:35 PM8/9/20
to Sparx Enterprise Architect General
Well, I did make myself quite a few scripts that could parse a whole tree and do something with their contents. The following one that looks closest to what you need. I suppose you would easily adapt it to your needs:

For reference on the theOBJECT.ObjectType == 5 (list of object types and their values) see picture in this article: https://blog.sparxsystems.de/en_GB/ea/ea-features/ea-model-search/enterprise-architect-datenmodell-ea-api/

!INC Local Scripts.EAConstants-JScript
!INC EAScriptLib.JScript-Dialog
function BulkChangeAuthor(){
Session.Output('BulkChangeAuthor Started');
var newAuthor=DLGInputBox('Who is the new papa?', '', '');
updateElementAndChildren(Repository.GetTreeSelectedObject(),newAuthor);
Session.Output('Finished!');
DLGInputBox('Finished!','','OK!');
}

function updateElementAndChildren(theOBJECT,newAuthor)
{
if (theOBJECT.ObjectType == 5 && theOBJECT.Element.Author !=newAuthor){ //if theOBJECT is a package
theOBJECT.Element.Author = newAuthor;
Session.Output('Package Author updated to '+theOBJECT.Element.Author);
theOBJECT.Element.Update();
}
if (theOBJECT.ObjectType == 4 && theOBJECT.Author !=newAuthor){//if theOBJECT is an element
theOBJECT.Author = newAuthor;
Session.Output('Element Author updated to '+theOBJECT.Author);
theOBJECT.Update();
}
if (theOBJECT.ObjectType == 5 && theOBJECT.Packages.Count >0){ //go through all child packages
var packagesEnumerator = new Enumerator(theOBJECT.Packages);
Session.Output('Child Packages found! Processing.');
while (!packagesEnumerator.atEnd()){
Session.Output('Package to process is ' + packagesEnumerator.item().Name);
updateElementAndChildren(packagesEnumerator.item(),newAuthor);
packagesEnumerator.moveNext();
}
}
if (theOBJECT.Elements.Count >0){ //go through all child elements
var elementEnumerator = new Enumerator(theOBJECT.Elements);
Session.Output('Child Elements found! Processing.');
while (!elementEnumerator.atEnd()){
Session.Output('Element to process is ' + elementEnumerator.item().Name);
updateElementAndChildren(elementEnumerator.item(),newAuthor);
elementEnumerator.moveNext();
}
}
}

BulkChangeAuthor();




четверг, 6 августа 2020 г., 10:36:41 UTC+3 пользователь Z L написал:
Reply all
Reply to author
Forward
0 new messages