Book a Demo

Author Topic: How to set stereotype using C# API  (Read 4899 times)

sravang

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
    • View Profile
How to set stereotype using C# API
« on: November 18, 2020, 01:14:30 pm »
Hello Everyone,
I have a query on the way Stereotypes are set using the C# API.
I am using EA 15 and using C# API i am trying to create Requirements, i want to set the Stereotype as 'requirement' (SysML Requirement),
so i set

EA.Element ele = package.Elements.Add("Test Req", "Requirement");
ele.StereotypeEx = "requirement";
ele.update();

The issue is after i save the element the Stereotype changes to 'Requirement' from 'requirement', which messes my element.
Am i doing something wrong here, do i need to set some other properties?

Any pointers would be helpful, Thanks

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: How to set stereotype using C# API
« Reply #1 on: November 18, 2020, 02:27:43 pm »
Hello Everyone,
I have a query on the way Stereotypes are set using the C# API.
I am using EA 15 and using C# API i am trying to create Requirements, i want to set the Stereotype as 'requirement' (SysML Requirement),
so i set

EA.Element ele = package.Elements.Add("Test Req", "Requirement");
ele.StereotypeEx = "requirement";
ele.update();

The issue is after i save the element the Stereotype changes to 'Requirement' from 'requirement', which messes my element.
Am i doing something wrong here, do i need to set some other properties?

Any pointers would be helpful, Thanks
Hi Sravang,
You probably need to set the profile name to get the correct SYSML stereotype.   Try "SysML::requirement"

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to set stereotype using C# API
« Reply #2 on: November 18, 2020, 04:01:54 pm »
Hi Sravang,
You probably need to set the profile name to get the correct SYSML stereotype.   Try "SysML::requirement"

HTH,
Paolo

That might need to be "SysML1.4::requirement", depending on the version you are using.
In version 15 you can actually see the fully qualified stereotype in the properties. Use that to set StereotypeEx

Geert

integrationsmaster

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: How to set stereotype using C# API
« Reply #3 on: November 18, 2020, 06:05:59 pm »
Quote
That might need to be "SysML1.4::requirement", depending on the version you are using.
In version 15 you can actually see the fully qualified stereotype in the properties. Use that to set StereotypeEx

I also have a similar issue, where do i find the full stereotype, if i look at the StereoType, StereoTypeEx properties they only show the base version, in this case, 'requirement'. Is there a property i can look at to get the full value "SysML1.4::requirement"

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to set stereotype using C# API
« Reply #4 on: November 18, 2020, 06:13:49 pm »
You can either look in the GUI (as of 15.1 I believe). There fully qualified stereotype will be displayed there.
Or you can look in the database table t_xref
Or use the new property EA.Element.FQStereotype

Geert

integrationsmaster

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: How to set stereotype using C# API
« Reply #5 on: November 19, 2020, 01:30:12 am »
Or use the new property EA.Element.FQStereotype

Geert

This worked, thanks