Book a Demo

Author Topic: Delete a connector from an element  (Read 4485 times)

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Delete a connector from an element
« 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
Models are great!
Correct models are even greater!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Delete a connector from an element
« Reply #1 on: January 15, 2011, 04:43:41 am »
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

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: Delete a connector from an element
« Reply #2 on: January 15, 2011, 08:03:32 pm »
thats how i do it.

Code: [Select]
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);
        }

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Delete a connector from an element
« Reply #3 on: January 16, 2011, 02:15:59 am »
Many thanks for the replies, I will try these ideas out when I return the office on Monday

Cheers

Phil
Models are great!
Correct models are even greater!