Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: R Glenn Walker on March 06, 2024, 10:54:54 am

Title: Setting direction on connectors
Post by: R Glenn Walker 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();
         }
Title: Re: Setting direction on connectors
Post by: qwerty 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.
Title: Re: Setting direction on connectors
Post by: R Glenn Walker 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.
Title: Re: Setting direction on connectors
Post by: Geert Bellekens 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