Book a Demo

Author Topic: [Solved]Direction of connector is not changed by Jscript & VB script  (Read 7789 times)

demian824

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Hello,

I tried to change direction of bunch of connectors to "Source -> Destination" by Jscript & VB script.
However, only direction property is not changed through the script.
I tried to both re-create connectors with the direction and update their direction, directly, but all their directions will be changed to "Destination -> Source" after updating.
Could you please check my scripts if I made the mistake?
If my scripts are okay, please fix the issue.

JScript :
-Change direction
         var thePackage as EA.Package;
         thePackage = Repository.GetTreeSelectedObject();
         var elements as EA.Collection;
         elements = thePackage.Elements;
         var theEle as EA.Element;
         var direction = "Source -> Destination";

         for(var i = 0; i < elements.Count; i++){
            theEle = elements.GetAt(i);
            
            var connectors as EA.Collection;
            connectors = theEle.Connectors;
               
            
            for(var j = 0; j < connectors.Count; j++){
               var conn as EA.Connector;
               conn = connectors.GetAt(j);               
               conn.Direction = direction;
               conn.Update();
               connectors.Refresh();
            }
            theEle.Update();
            theEle.Refresh();
            Session.Output((i + 1)  +" / " + elements.Count + " is Done.");
         }

-Create new connector
function addConn(sourceId, targetId, connType){
   var connectors as EA.Collection;
   var target as EA.Element;
   target = Repository.GetElementByID(targetId);
   var source as EA.Element;
   source = Repository.GetElementByID(sourceId);
   connectors = target.Connectors;
   
   var newConn as EA.Connector;
   newConn = connectors.AddNew("", connType);
   newConn.SupplierID = target.ElementID;
   newConn.ClientID = source.ElementID;
   newConn.Direction = "Source -> Destination";
   newConn.Update();
   connectors.Refresh();
}

vb Script:
         for each theConn in connCollection
            
            theConn.Direction = "Source -> Destination"
            If theConn.Update() then
               count = count + 1
               connCollection.Refresh()
            end if
            Session.Output count
            Session.Output theConn.Direction
         next
         Session.output("Done")

Thanks,

WonChul Choi
« Last Edit: March 07, 2024, 02:55:14 am by demian824 »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Direction of connector is not changed by Jscript & VB script
« Reply #1 on: March 06, 2024, 09:25:36 pm »
In order to swap you have to swap source and taget objectId of the connector. All your Refresh calls are pointless.

q.

demian824

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: Direction of connector is not changed by Jscript & VB script
« Reply #2 on: March 07, 2024, 01:36:41 am »
In order to swap you have to swap source and taget objectId of the connector. All your Refresh calls are pointless.

q.

Negative. I tried that the direction is still Destination to Source.
Hence, I do not want to change source and target for my requirements

demian824

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: [Solved]Direction of connector is not changed by Jscript & VB script
« Reply #3 on: March 07, 2024, 02:56:12 am »
I changed the property 'Navigable' on connectorEnd Class.
now it is worked.