Book a Demo

Author Topic: Converting Elements from one type to another  (Read 7546 times)

stevesavage

  • EA User
  • **
  • Posts: 119
  • Karma: +4/-0
    • View Profile
Converting Elements from one type to another
« on: November 01, 2011, 07:34:00 am »
Summary:
Looking for info on ELEMENT.SynchTaggedValues(String,String)

Background:
Occasionally I will add an element to the repository as a specific MDG stereoType and then change my mind.  Instead of deleting and re-creating the element, I wanted to be able to "convert".

The builtin option "Element -> Advanced -> Change type" work's ok, but I wanted to create an API script that would let me "bulk convert" elements from one type to another, including adding any required tagged values.

I've got most of this working.

For the initial "conversion" I set:

.Type = inType;
.StereoType = inStereotype;
.StereoTypeEx = inStereotype; * unless you want multiple stereoTypes
.MetaType = inMetaType;

This give's me most of what I need.

I can then manually sync, by selecting the stereotype in the toolbox, and selecting (rightMouse -> Synchonize Stereotype).

But, I would prefer that this all happens as part of the script.
There is the function ELEMENT.SynchTaggedValues(String,String)

But I can't find any information on this function, or the two strings.  I tried StereoType,Type (and Type,StereoType) , but that didn't seem to work.

Any ideas?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Converting Elements from one type to another
« Reply #1 on: November 01, 2011, 07:46:49 pm »
What? Where did you find this method???

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Converting Elements from one type to another
« Reply #2 on: November 02, 2011, 09:28:57 am »
Profile, Stereotype
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Converting Elements from one type to another
« Reply #3 on: November 02, 2011, 08:23:24 pm »
So its actually Repository.SynchProfile?

q.

stevesavage

  • EA User
  • **
  • Posts: 119
  • Karma: +4/-0
    • View Profile
Re: Converting Elements from one type to another
« Reply #4 on: November 04, 2011, 01:59:17 am »
I found it when I was creating my script in the EA editor, you can type EA.Element. and get a list of all the functions.  I couldn't find it in the built in or online help.

EA.Element.SynchTaggedValues is one of the options.

Thanks, that worked.

e.g. to convert an element to a "Policy" element under the ToGAF profile

theElement.Type = inType;
theElement.StereoType = inStereotype;
theElement.StereoTypeEx = inStereotype;
theElement.MetaType = inMetaType;
theElement.SynchTaggedValues("TOGAF",inStereotype);
theElement.Update();
Repository.AdviseElementChange(theElement.ElementID);

I'm really liking the built in api, and have been building up an extensive library of scripts to "enhance" EA.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Converting Elements from one type to another
« Reply #5 on: November 04, 2011, 06:26:32 am »
Strange, however. Please Sparxians, would you document such things in your help before making it available in this way.

q.

Pawel Jasinski

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
Re: Converting Elements from one type to another
« Reply #6 on: December 18, 2011, 08:09:09 pm »
hi,

i know this thread is a bit old but ...
Did any of you got the element.synchTaggedValue to work outside of EA scripting (e.g. connected via COM from vb or c# with interoperability assembly)?
If yes, could you tell me which version of EA it is and perhaps drop a snipped. I am sure I am missing some "obvious" detail.

http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1323957736

Thanks
Pawel