Book a Demo

Author Topic: Sequence Diagramming Questions  (Read 2586 times)

Octavian

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Sequence Diagramming Questions
« on: May 05, 2011, 08:14:55 am »
Hello all,

Anybody know solutions to these issues:
1. Somebody made a sequence diagram in my project without using the proper reusable entities (lifelines). Is there a way for me to substitute whatever entity they put in the diagram with the reusable ones? I need to do it without breaking the connections.
2. I need two sequence diagrams to merge. How do I append one to the other? This is of course assuming the same entities are involved?
3. Is there a way to export one diagram to JPG, PNG or any other common format without reporting?

Thank you in advance!
Octavian

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Sequence Diagramming Questions
« Reply #1 on: May 05, 2011, 04:38:01 pm »
Octavian,

1. Yes you can, via automation. You'll need to set ElementID of the DiagramObject to the Element you want.
Here's the code I use (tested on 8.0.850)
Code: [Select]
       public void setElement(UMLElement element)
        {
            // there seems to be a bug in the com object when calling update on the DiagramObject after setting the elementID
            // workaround could be to create a new diagramObject on the diagram and copy all the settings
            EA.Diagram parentDiagram = model.getWrappedModel().GetDiagramByID(this.wrappedDiagramNode.DiagramID);
            //get the index of this diagramnode in the collection of diagramobjects of the parent
            short index = -1;
            for (short i = 0; i < parentDiagram.DiagramObjects.Count; i++)
            {
                if (((EA.DiagramObject)parentDiagram.DiagramObjects.GetAt(i)).InstanceID == this.wrappedDiagramNode.InstanceID)
                {
                    //found the correct one.
                    index = i;
                }
            }
            //create a new diagramobject
            EA.DiagramObject newDiagramObject = (EA.DiagramObject)parentDiagram.DiagramObjects.AddNew("", "DiagramObject");
            //set the new elementid
            newDiagramObject.ElementID = element.getID();
            //copy position attributes
            newDiagramObject.bottom = this.wrappedDiagramNode.bottom;
            newDiagramObject.left = this.wrappedDiagramNode.left;
            newDiagramObject.right = this.wrappedDiagramNode.right;
            newDiagramObject.top = this.wrappedDiagramNode.top;
            //delete the old diagram object
            parentDiagram.DiagramObjects.Delete(index);
            //reference the new diagram object
            this.wrappedDiagramNode = newDiagramObject;
            // bug reported to Sparx support. If they fix it this original code can be used again.
            //original code: this.wrappedDiagramNode.ElementID = element.getID();
            
        }
2. Again via automation you could move the messages from one diagram to another.
3. Using the GUI: Ctrl-T, via automation using Project.PutDiagramImageToFile

Geert