Book a Demo

Author Topic: Scripting : copy diagram between packages  (Read 18031 times)

Danny F

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: Scripting : copy diagram between packages
« Reply #15 on: October 12, 2012, 08:12:10 pm »
@pakcom

Sorry I have to ask .... :-[

In your script scenario :
Add new connector and copy the attributes from original connector. Update new connector.

Add new connector to what ???

thanks

Reg.

Danny

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Scripting : copy diagram between packages
« Reply #16 on: October 12, 2012, 08:16:10 pm »
You have to add connectors to either the source or the target element.
Something like
Code: [Select]
mySourceElement.Connectors.AddNew("name","type");
Geert

Danny F

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: Scripting : copy diagram between packages
« Reply #17 on: October 12, 2012, 08:36:59 pm »
thanks for the very quick response Geert :)

that's what I thought - and did (adding to the source element - which is linked by the new DiagramObject on my new diagram)
but then I add a connector to the original element and doing so I change the original diagram ( this new connector is also visible in the source diagram) ???


surely I'm doing something stupidly wrong  :(
Reg.

Danny

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Scripting : copy diagram between packages
« Reply #18 on: October 12, 2012, 08:41:44 pm »
Danny,

In case of sequence diagrams, it works differently then with regular diagrams.

For sequence diagrams you need to set the diagramID on the connector to determine on which diagram it shows.

For all other diagrams, if both the source and the target element are shown on a diagram EA will automatically show every connector between those two on the diagram. (unless you specifically hide it)

Geert

pakcom

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Scripting : copy diagram between packages
« Reply #19 on: October 12, 2012, 08:43:38 pm »
This is what I do to add new connector and copy the attribute from the old one.

Code: [Select]
EA.Connector sourceConnector = Repository.GetConnectorByID(sourceDiagramLink.ConnectorID);
EA.Connector new_con = source_element.Connectors.AddNew(sourceConnector.Name, sourceConnector.Type);

new_con.DiagramID = newDiagram.DiagramID;

// copy connector properties
new_con.SupplierID = sourceConnector.SupplierID;
new_con.Direction = sourceConnector.Direction;
new_con.EndPointX = sourceConnector.EndPointX;
new_con.EndPointY = sourceConnector.EndPointY;
new_con.EventFlags = sourceConnector.EventFlags;
new_con.StartPointX = sourceConnector.StartPointX;
new_con.StartPointY = sourceConnector.StartPointY;
new_con.Width = sourceConnector.Width;
new_con.SequenceNo = sourceConnector.SequenceNo;
new_con.IsLeaf = sourceConnector.IsLeaf;
new_con.IsRoot = sourceConnector.IsRoot;
new_con.RouteStyle = sourceConnector.RouteStyle;
new_con.StyleEx = sourceConnector.StyleEx;
new_con.VirtualInheritance = sourceConnector.VirtualInheritance;
new_con.EventFlags = sourceConnector.EventFlags;
new_con.IsSpec = sourceConnector.IsSpec;
new_con.Notes = sourceConnector.Notes;

new_con.Update();

In my case, the original diagram doesn't change.

regards,
com

Danny F

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: Scripting : copy diagram between packages
« Reply #20 on: October 12, 2012, 09:03:44 pm »
@Geert : thanks
@pakcom : thanks - you do as Geert's remark - you have to set the diagramID in the connector

simpel (if you know it)

It works now  [smiley=2vrolijk_08.gif]
Reg.

Danny