Author Topic: Setting direction on connectors  (Read 11527 times)

R Glenn Walker

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • Be the change you envision in others.
    • View Profile
    • Glenn the dotConsultant
Setting direction on connectors
« on: March 06, 2024, 10:54:54 am »
I have written a simple script that creates composition links between an element and any child elements. It works except that when I try to set the direction, I don't get the effect for which I am looking to achieve. I want "Source -> Destination". But it always sets it to "Destination -> Source". I

         var theElement as EA.Element;
         theElement = Repository.GetTreeSelectedObject();
         
         elements = new Enumerator(theElement.Elements);
         while (!elements.atEnd()) {
            var element as EA.Element;
            element = elements.item();
            connector = element.Connectors.AddNew("Part Of","composedOf");
            connector.SupplierId = theElement.ElementID;
            connector.Direction = "Source -> Destination";
                                 // Assuming need update here so that the supplier end is filled in properly.
            connector. Update();
                                // this works fine. Aggregation is showing properly.
            connector.SupplierEnd.Aggregation = 2;
            connector.Update();
            elements.moveNext();
         }
Glenn Walker
Solution Architect

qwerty

  • EA Guru
  • *****
  • Posts: 13544
  • Karma: +395/-300
  • I'm no guru at all
    • View Profile
Re: Setting direction on connectors
« Reply #1 on: March 06, 2024, 09:27:16 pm »
Aggregation links are subtle (you will find quite a number of ancient posts by Paolo here). Just use source and target the opposite way you tried.

q.

R Glenn Walker

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • Be the change you envision in others.
    • View Profile
    • Glenn the dotConsultant
Re: Setting direction on connectors
« Reply #2 on: March 29, 2024, 08:27:42 am »
Have tried both ways. But, no joy. The aggregation property is set properly. At this point, I am left with manually selecting and changing the direction of each link.
Glenn Walker
Solution Architect

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13065
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Setting direction on connectors
« Reply #3 on: March 29, 2024, 08:15:23 pm »
I recently had the same issue.

It worked when I set the ConnectorEnd.Navigable property

https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/connectorend.html

Geert