5
votes

I have a project with several diagrams (with elements). I want to close this particular project and move the diagrams to other more suitable projects.

Moving a diagram is simple. Problem is that now I have to manually find all related element to this particular diagram and move them one by one to the other project. As I have quite a few elements in all diagrams in the original project this is quite tedious.

I wonder if there's an easier way of handling refactoring like this in EA?

3

3 Answers

5
votes

There is no easier way in out-of-the-box EA, no. But where there's a will there's a way.

First off, make a copy of your project. The solution I'm describing will destroy its structure.

Second, create an empty package and move the diagram there.

Third, create a VBScript in the Browserscript group (Tools - Scripting). Call it "Collect Diagram Elements". In the editor, replace the commented-out otDiagram case with the following:

case otDiagram
    ' Code for when a diagram is selected
    dim theDiagram as EA.Diagram
    set theDiagram = Repository.GetTreeSelectedObject()
    dim dObj as EA.DiagramObject
    dim element as EA.Element
    for each dObj in theDiagram.DiagramObjects
        set element = Repository.GetElementByID(dObj.ElementID)
        element.PackageID = theDiagram.PackageID
        element.Update()
    next

This script runs through all the elements shown in a diagram and moves them to the package the diagram is in.

Run the script by right-clicking the diagram in the package browser and selecting Scripts - Collect Diagram Elements. After the script finishes, you may need to reload the package (right-click the package in the package browser, select Contents - Reload Current Package).

Finally, export the package to XMI (right-click in the package browser, select Import/Export - Export Package to XMI File), and then import it into your target project.

0
votes

You can also try to put you diagramme inside a package and then export it to XML file and import it from the destination project.

-1
votes

This might help:

FOR EA VERSION 15

Project 1 - from where you want to copy a diagram

  1. Do a Ctrl+A (select all) on your diagram.
  2. Publish -> Save -> Save to Clipboard.

Project 2 - where the diagram will be pasted

  1. Create an empty diagram.
  2. Right-Click (on the empty diagram) -> Paste -> Image from Clipboard

FOR EA VERSION 10

Project 1 - from where you want to copy a diagram

  1. Do a Ctrl+A (select all) on your diagram.
  2. Edit -> Project Clipboard -> Add to Project Clipboard.

Project 2 - where the diagram will be pasted

  1. Create an empty diagram.
  2. Edit -> Paste Image from Clipboard.

This will copy the diagram as a whole image (single component) and I think you will not be able to change the actual components of the diagram once it is pasted in the new project.