Author Topic: Diagram script: selected element feature  (Read 211 times)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1073
  • Karma: +81/-5
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Diagram script: selected element feature
« on: October 06, 2017, 06:27:38 pm »
Hey guys,


Is there a way to retrieve the currently selected element feature (I mainly need attributes and operations) in a diagram?

The information is there, because you can right-click an operation and find it in the project browser -- but is it available in the API? All I can get out of the Diagram class is the selected connector and elements.

It's no, right? The answer is no?


/Uffe
My theories are always correct, just apply them to the right reality.

Helmut Ortmann

  • EA User
  • **
  • Posts: 884
  • Karma: +37/-1
    • View Profile
Re: Diagram script: selected element feature
« Reply #1 on: October 06, 2017, 07:26:50 pm »
Hi Uffe,

you can access the selected attribute, operation by script. The snippet in C#. You have to translate it into your Scripting Language. The API ist the same:


Code: [Select]
ObjectType objectType = _model.Repository.GetContextItemType();
int id;
switch (objectType) {
  case ObjectType.otAttribute:
  id = ((EA.Attribute)_model.Repository.GetContextObject()).AttributeID;
}

Best regards,

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1073
  • Karma: +81/-5
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Diagram script: selected element feature
« Reply #2 on: October 06, 2017, 10:22:34 pm »
Heeeey,

Yes! That works! :)

Now unfortunately, if you select an attribute or operation in a diagram and right-click it, there's no Script sub-menu.

But you can select the feature first, then move the cursor to some other part of the element and right-click, and the script will pick up the selection. So that's close enough.

Thanks!


/Uffe
My theories are always correct, just apply them to the right reality.