Author Topic: Change Stereotype for an ArchiMate 3 Element  (Read 2851 times)

mhuebsch

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Change Stereotype for an ArchiMate 3 Element
« 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).

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Change Stereotype for an ArchiMate 3 Element
« Reply #1 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.

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1311
  • Karma: +120/-10
  • Its the results that count
    • View Profile
Re: Change Stereotype for an ArchiMate 3 Element
« Reply #2 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.
Happy to help
:)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13326
  • Karma: +558/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Change Stereotype for an ArchiMate 3 Element
« Reply #3 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

mhuebsch

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Change Stereotype for an ArchiMate 3 Element
« Reply #4 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!