Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: philchudley on January 15, 2011, 04:19:59 am
-
Hi All,
How do you remove a connector from an element. I have tried using the Delete and DeleteAt methods followed by a Refresh for the Elements's connectors collection.
Examine the size of the collection confirms that something has in fact been deleted, but examination of the Element's propery dialog Links tab shows the connector to still be there!
It is also present on all diagrams where this element is present.
Do I also have to remove the connector from the Diagram's DiagramLinks collection as well?
The code examples in the User Guide show the creation of a new connector (no diagram is necessary), but do not show the removal of a connector.
Any advice will be most appreciated
Cheers
Phil
-
Phil,
I guess deleting it from the Connectors collection should be enough (with a refresh maybe, I'm not sure about that)
Are you sure the model you are looking at with the GUI has already been reloaded?
You might just be seeing a cached copy of the Connector.
Geert
-
thats how i do it.
public static void deleteConnector(EA.Connector con, EA.Repository Repository)
{
EA.Element client = Repository.GetElementByID(con.ClientID);
EA.Diagram actDiag = Repository.GetCurrentDiagram();
short i = 0;
foreach (EA.Connector actLink in client.Connectors)
{
if (actLink.ConnectorID == con.ConnectorID)
{
client.Connectors.Delete(i);
}
i++;
}
Repository.ReloadDiagram(actDiag.DiagramID);
}
-
Many thanks for the replies, I will try these ideas out when I return the office on Monday
Cheers
Phil