Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: mhuebsch on November 10, 2023, 10:26:16 am

Title: Change Stereotype for an ArchiMate 3 Element
Post by: mhuebsch on November 10, 2023, 10:26:16 am
Due to reclassification of software in our Service Management system, some of my (ArchiMate 3) ArchiMate_ApplicationComponent elements will need to change to ArchiMate_ApplicationInterface, ArchiMate_ApplicationProcess, or ArchiMate_DataObject elements. I'd like to do this using a spreadsheet of the affected elements as an input to a VBscript. I've discovered that simply updating the element.Stereotype won't work. I've also tried resetting the element.Type and element.Stereotype and then updating the element, but this results in some unusual behavior depending on what type of element it's being changed to. Has anyone done something similar with consistently good results? P.S. I do understand that certain relationships will need to change (like Access).
Title: Re: Change Stereotype for an ArchiMate 3 Element
Post by: qwerty on November 10, 2023, 11:31:14 am
Changing stereotyped via script is usually pretty straight forward. "Some script you found on the net" is more like "won't work". In detail things can be more complicated. Sometimes stereotype X from profile A applies to another element than the targeted Y from profile B. In that case you cam not simply assign a new stereotype but mist create a new element (and later get rid of the source). Migrating a profile can be a difficult thing. Know what you have to do or get yourself some help.

q.
Title: Re: Change Stereotype for an ArchiMate 3 Element
Post by: Sunshine on November 10, 2023, 04:27:10 pm
Try using element.stereotypeEx() followed by element.update(). If you search the forum you should find some jscript I posted a while back.
Title: Re: Change Stereotype for an ArchiMate 3 Element
Post by: Geert Bellekens on November 10, 2023, 06:24:16 pm
As Sunshine indicates, the trick is to use StereotypeEx with the fully qualified stereotype.

So something like

Code: [Select]
myElement.SteretoypeEx = "ArchiMate3::ArchiMate_ApplicationComponent"
myElement.Update

But before you do that, check that the myElement.Type corresponds the the expected basetype for the stereotype you are setting.
Make sure to update() the element after changing the type, or EA won't be able to set the stereotype correctly

Geert
Title: Re: Change Stereotype for an ArchiMate 3 Element
Post by: mhuebsch on November 21, 2023, 06:05:30 am
Ah, good point, Geert. I found basetypes in the MDG and my script now seems to be working! Big thanks to Geert and Sunshine!