Book a Demo

Author Topic: Adding Method to Activity Diagram  (Read 4835 times)

njf

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Adding Method to Activity Diagram
« on: February 23, 2013, 04:22:56 pm »
Hi,

I am trying to add an Element's method to an Activity Diagram via the API, but I cannot figure how to replicate how it is done when you do it via the GUI.

On the GUI, it seems to create an 'Action' object (which I assume is a type of Element) and an 'Action Pin'. How do I make an 'Action Pin' via the API?

BTW - I used the API a couple of years ago and seem to remember there was a request you could execute which showed what changes were made to the EAP database when a user made changes on the GUI. This would be really useful in figuring this issue out. Does such a command exist or am I imagining things?!

Thanks,
njf

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Adding Method to Activity Diagram
« Reply #1 on: February 24, 2013, 02:48:58 am »
Use
Code: [Select]
elem.Elements.AddNew ("name", "ActionPin") to create a new Action Pin (the docu does not seem to tell us, but it works).

To be aware of user interactions use the broadcast event EA_OnContextItemChanged


q.

njf

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Adding Method to Activity Diagram
« Reply #2 on: February 24, 2013, 09:47:30 pm »
Thanks qwerty! I should really have tried the obvious first!

I have got the methods to show on the diagram (as Actions) and was able to connect them together. But I can't get them to be vertically aligned via the api. If the functions to align are not available through the api, I thought I could calculate the correct placements by using the left, right attributes of the diagram object but these don't seem to be accurate.

Any ideas on how I can get around this?
« Last Edit: February 24, 2013, 09:48:29 pm by neilf75 »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Adding Method to Activity Diagram
« Reply #3 on: February 25, 2013, 12:28:30 am »
If you're on V10 the placement of embedded elements via API is broken. I have reported that after a reader told me that the example in my book did not work. Here's what they replied:
Quote
Thank you for your report.

We have been able to reproduce the scenario described in your report and
this will be investigated further by our development team.

Your reference number for this issue is 13024568.

Unfortunately we cannot provide any schedule for this issue to be
resolved as yet.  If you wish to request the status of this issue at a
later time, please quote the above reference number in your enquiry.
Back in V9.3 this did work.

q.
« Last Edit: February 25, 2013, 12:29:46 am by qwerty »

njf

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Re: Adding Method to Activity Diagram
« Reply #4 on: February 25, 2013, 09:59:13 pm »
Thanks for your advice. I will leave this for now - I am using version 10 at the moment.

Just one last question, is there a way to "auto route" the connectors (similar to the option in the layout tools tab)?

I know you can add a diagramLink to a connector and from reading through other topics it seemed if you set the mode to 2 or 3 (tried both) within the style attribute, it would then use the auto route option. But I found this not to be the case, the connectors still ran across elements in the diagram.

I'm assuming all the other geometry settings and file path attributes have to be setup as well. I was hoping there would just be a call I could make from the API to setup all the diagramLink attributes on a diagram.

I know I could do this manually but I'm producing a lot of activity diagrams in one go and I would prefer to automate the process.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding Method to Activity Diagram
« Reply #5 on: February 25, 2013, 10:36:05 pm »
I guess you are looking for Project Interface.LayoutDiagramEx()

Geert