Book a Demo

Author Topic: How to create MDG elements from an AddIn  (Read 6686 times)

Jeff Bartels

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
How to create MDG elements from an AddIn
« on: September 30, 2014, 05:34:14 am »
I am developing an Add-In and have some questions about manipulating elements defined in a custom MDG technology from the EA API. I have been scouring the forums and EA user guide and am not finding any relevant information.

In essence, I need to be able to do the equivalent of the interactive Create Element operation in the Project Browser (4th icon from the left at the top of the PB frame) from an AddIn using the automation API. The associated interactive steps include:
- Selecting the active toolset
- Selecting the custom MDG element type



When examining the created element with the Element properties dialog, the element shows a setoff tagged values that is distinct from the standard set named "Tagged Values". I am also wondering how to get at this distinct set of Tagged Values using the API.


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to create MDG elements from an AddIn
« Reply #1 on: September 30, 2014, 07:17:30 am »
Depends on your version. With V11 (and probably V10) you can just assign the stereotype like <profile>::<stereo>(I guess for SysML that would be e.g. SysML1.3::theStereo). I don't have SysML so I can't tell. Look into the MDG file to find it out.

q.

Jeff Bartels

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: How to create MDG elements from an AddIn
« Reply #2 on: September 30, 2014, 02:33:19 pm »
Thanks qwerty I'll try that out

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: How to create MDG elements from an AddIn
« Reply #3 on: September 30, 2014, 08:03:57 pm »
Hi Jeff

If i've understood the question i.e. to programmactically create an element associated with an MDG and set all the relevant tagged values for the new element.  Then sequence I use is as follows:


Create an element setting its type and stereotype (I assume you will set these to valid values for your selected MDG)

e.g.

myElement.Type = set element
myElement.Stereotype = set stereotype


Then sync element to required MDG  - from the Sparx manual SynchTaggedValues (string Profile, string Stereotype)

e.g.
myElement.SynchTaggedValues("myMDGNAME", myElement.Stereotype)  - this sets the distinct set of tagged values

Your new element will then have a new "MDG" element with default values.

Hope that helps.

« Last Edit: September 30, 2014, 08:04:40 pm by MrWappy »
EXploringEA - information, utilities and addins

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to create MDG elements from an AddIn
« Reply #4 on: September 30, 2014, 08:46:19 pm »
You don't need sync MDG stereotype with the later EA versions. In 9.3 and before you needed to do that and the way TVs are created differs.

q.

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: How to create MDG elements from an AddIn
« Reply #5 on: September 30, 2014, 09:54:42 pm »
@qwerty  thanks for the info - of course another inconsistency to cater for :(
EXploringEA - information, utilities and addins

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to create MDG elements from an AddIn
« Reply #6 on: October 01, 2014, 12:16:32 am »
Well, in that case I would not call it inconsistent since it is something made new. The new behavior has pros and cons but overall I'd say it is an improvement. I'd rather like to see some more features thrown over board ;)

q.

Jeff Bartels

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: How to create MDG elements from an AddIn
« Reply #7 on: October 04, 2014, 03:37:03 am »
Problems all solved, questions answered.
I'm using EA 10. The following calls create the desired element using our custom MDG:

        Dim elem As EA.Element = Nothing
        elem = DirectCast(pkg.Elements.AddNew("test", "Requirement"), EA.Element)
        elem.StereotypeEx = MDGInformation.ProfileName & "::" & MDGInformation.Stereotype
        elem.Update()

Calling AddNew with the profile name and stereotype string causes EA to throw and exception.

Finally, the tagged values that our MDG adds to the the Requirement object are accessible in the API via the TaggedValues property of the Element object, even though in the EA app the property window segregates the MDG-related tagged values from the TaggedValues property.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to create MDG elements from an AddIn
« Reply #8 on: October 04, 2014, 06:11:16 am »
You should report a bug regarding the exception you get. It might be fixed in V11, though. I don't know but the supporters likely will.

q.