Author Topic: Adding ActivityParameters to ActivityDiagram via EA API  (Read 8 times)

vrieg

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
Adding ActivityParameters to ActivityDiagram via EA API
« on: May 25, 2024, 10:32:14 pm »
Hello all,

I want to use EA APi to add ActivityParameters to an ActivityDiagram.
I have added the Activities and identified the GUID of the ActivityParameters correctly.
However, when I am trying to update the diagramobject I am running into a stack overflow during execution.

Does anyone know what could be the issue?
It seems to be this line parameterDiagramObject.Update();
And it is independently caused for iterating through EA.Elements or EA.Diagobjects to add the diagramobject to the diagram.

Adding the ActivityParameters manually via, Features/InteractionPoints/Show works perfectly. However I would like to automate this step if possible.


Code: [Select]

 public static void ShowActivityParametersInDiagram(string activityDiagramGUID, string activityGUID,EA.Repository Repository, OutputMyTab outputTab)
        {
            // Retrieve the EA.Element for the activity using its GUID
            EA.Element activityElement = Repository.GetElementByGuid(activityGUID);
            EA.Diagram activityDiagram = Repository.GetDiagramByGuid(activityDiagramGUID);

            if (activityDiagram != null && activityElement !=null)
            {
              foreach (EA.Element parameter in activityElement.Elements)
                {
                    EA.DiagramObject parameterDiagramObject = activityDiagram.DiagramObjects.AddNew("", "");
                    parameterDiagramObject.ElementID = parameter.ElementID;
                    parameterDiagramObject.Update();                 
                   }
            }
            activityDiagram.Update();
            }
            else
            {
               
                outputTab.WriteDebugMsg($"Error: Unable to retrieve activityDiagram for GUID: {activityDiagramGUID}");
            }
        }