Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: vrieg 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.
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}");
}
}
-
Hard to tell without the stack trace. However, the activityDiagram.Update is superfluous since you do not change the diagram properties.
q.
-
Try asking copilot to create the script for you may give you some hints.
-
I have a shapescript on the ActivityParameters to visualize the direction for in and out.
If I look into the xml of the manually generated ActrivitiyParameters obtained bey Features/InteractionPoints/ShowAll, I am getting this for the diagram objects however, printing digaramobject.sequence or diagramobject.style return 0 for each entry.
Is there a way how to set those parameters before.diagramobject.update()?
I am just wondering if this could cause the stackoverflow.
<Table name="t_diagramobjects">
<Row>
<Column name="Diagram_ID" value="2011"/>
<Column name="Object_ID" value="25696"/>
<Column name="RectTop" value="-95"/>
<Column name="RectLeft" value="50"/>
<Column name="RectRight" value="190"/>
<Column name="RectBottom" value="-145"/>
<Column name="Sequence" value="4"/>
<Column name="ObjectStyle" value="DUID=B9E218C5;"/>
<Column name="Instance_ID" value="23741"/>
<Extension Diagram_ID="{3EAE5DB3-7462-4654-9275-A40541AE92F5}" Object_ID="{EF479DC4-F6E3-46c0-AD69-2651BE55DE84}"/>
</Row>
<Row>
<Column name="Diagram_ID" value="2011"/>
<Column name="Object_ID" value="25743"/>
<Column name="RectTop" value="-88"/>
<Column name="RectLeft" value="135"/>
<Column name="RectRight" value="170"/>
<Column name="RectBottom" value="-103"/>
<Column name="Sequence" value="1"/>
<Column name="ObjectStyle" value=" DUID=82CBCB57;LBL=CX=284:CY=14:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=1:ALT=0:ROT=0;"/>
<Column name="Instance_ID" value="23747"/>
<Extension Diagram_ID="{3EAE5DB3-7462-4654-9275-A40541AE92F5}" Object_ID="{2204DF86-B848-4923-AAD5-B4BF35CB94E9}"/>
</Row>
<Row>
<Column name="Diagram_ID" value="2011"/>
<Column name="Object_ID" value="25742"/>
<Column name="RectTop" value="-88"/>
<Column name="RectLeft" value="95"/>
<Column name="RectRight" value="130"/>
<Column name="RectBottom" value="-103"/>
<Column name="Sequence" value="2"/>
<Column name="ObjectStyle" value=" DUID=985763BD;LBL=CX=284:CY=14:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=1:ALT=0:ROT=0;"/>
<Column name="Instance_ID" value="23748"/>
<Extension Diagram_ID="{3EAE5DB3-7462-4654-9275-A40541AE92F5}" Object_ID="{FAA98753-DF0B-4ff6-9986-526481237C4B}"/>
</Row>
<Row>
<Column name="Diagram_ID" value="2011"/>
<Column name="Object_ID" value="25741"/>
<Column name="RectTop" value="-86"/>
<Column name="RectLeft" value="50"/>
<Column name="RectRight" value="85"/>
<Column name="RectBottom" value="-101"/>
<Column name="Sequence" value="3"/>
<Column name="ObjectStyle" value=" DUID=08F7BAB9;LBL=CX=291:CY=14:OX=0:OY=0:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=1:ALT=0:ROT=0;"/>
<Column name="Instance_ID" value="23749"/>
<Extension Diagram_ID="{3EAE5DB3-7462-4654-9275-A40541AE92F5}" Object_ID="{17447D79-F5A8-462d-9F1F-C6F41DC60EDB}"/>
</Row>
</Table>