Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: demian824 on March 06, 2024, 05:15:41 am
-
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
-
In order to swap you have to swap source and taget objectId of the connector. All your Refresh calls are pointless.
q.
-
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
-
I changed the property 'Navigable' on connectorEnd Class.
now it is worked.