Book a Demo

Author Topic: How to get the ElementID of the Class of an Object  (Read 5881 times)

ThierryL

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
How to get the ElementID of the Class of an Object
« on: April 01, 2015, 09:16:12 am »
Hello !

I have a DiagramObject (in a sequence diagram) and I want to get the ElementId of the Class of this DiagramObject.

ObjectDiagram.ElementId returns the Id of the instance and it's not this that I want, but the Id of the Class of the instance.

Thank you for your help !

Best regards,
Thierry

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: How to get the ElementID of the Class of an Ob
« Reply #1 on: April 01, 2015, 09:57:54 am »
Once you have the Instance Element, you can get the ID of the class that it references from Element.ClassifierID.  For example:

Code: [Select]
diagramobject = [reference to DiagramObject from your sequence diagram]
theInstance = Repository.GetElementByID( diagramobject.ElementID );
if ( theInstance.Type == "Object" || theInstance.Type == "Sequence" )
{
      if ( theInstance.ClassifierID != 0 )
      {
            theClass = Repository.GetElementByID( theInstance.ClassifierID );
      }
}

ThierryL

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: How to get the ElementID of the Class of an Ob
« Reply #2 on: April 01, 2015, 10:16:19 am »
Thank you very much for your help Aaron B !!!  :)

Best regards,
Thierry