Author Topic: Adding Elements to a diagram  (Read 4602 times)

Bhupinder

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Adding Elements to a diagram
« on: May 18, 2004, 08:00:39 pm »
Hi,

Can anyone one let me know why I am getting this stange behaviour?

I am adding (through an EA Addin) several new DiagramObjects linking Existing Elements to Current diagram.

But the current diagram does not show my new elements - I am calling Update on both the new DiagramObject and the Diagram.

However if I ask EA to reload the same diagram (from context menu on diagram tabs in the diagram window) my newly added elements appear.

I have also tried calling Repository.ReloadDiagram but this makes no difference.


Would appreciate any help

thank you
Baz












Bhupinder

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Adding Elements to a diagram
« Reply #1 on: May 19, 2004, 06:24:33 am »
Some more info.

The Reload Diagram (&SaveDiagram) only fails to display the newly inserted diagram objects if the elements being added are not contained within the same package as the diagram.

Here is the sample Delphi code I am working on


var i, q : integer;
   Diagram     : IDualDiagram;
   DiagramObjs : IDualCollection;
   DiagramObj : IDualDiagramObject;
   Proj       : IDualProject;

   Exists     : Variant;

begin
 inherited;

 Diagram := Repository.GetCurrentDiagram;
 DiagramObjs := Diagram.DiagramObjects;

 //iterate through tree adding all the selected elements
 for i := 0 to pred (ElementList.Count) do
 begin
       

        //check if element has already been added
        q := 0;
        Exists := False;
        while ( q<= pred(DiagramObjs.Count)) and (Exists = Null) do
        begin
            Exists := IDualDiagramObject( DiagramObjs.GetAt(q) ).ElementID = Integer( ElementList.Objects );
            INC (q);
        end;

        if NOT Exists then
        begin
         
     //create the new diagram object and link to element / diagram

DiagramObj := DiagramObjs.AddNew(
                       format ( 'l=%d;r=%d;t=200;b=270;' ,[(130*i), (130*i) + 120 ]) , '')
                                                                         as IDualDiagramObject;

          DiagramObj.ElementID := Integer(ElementList.Objects);
          DiagramObj.DiagramID := Diagram.DiagramID;

          if not DiagramObj.Update then
             Showmessage( DiagramObj.GetLastError );

          if not Diagram.Update then
             Showmessage( Diagram.GetLastError );
        end;

 end;

 Repository.CloseDiagram (Diagram.DiagramID);
 Repository.OpenDiagram (Diagram.DiagramID);

 // Repository.ReloadDiagram(Diagram.DiagramID);


//layout the diagram
 Proj := repository.GetProjectInterface;
 Proj.LayoutDiagram(Diagram.DiagramGUID, 64);


Thanks in advance for any explainations.

Gobo

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: Adding Elements to a diagram
« Reply #2 on: May 24, 2004, 04:45:08 am »
Hey,
Additional question as far as LayoutDiagram is concerned.  Do You know how to set diagram properties, such as "Hide Attributes" or " Hide Operations". I can't find them inside EA.Diagram class.

Gobo
« Last Edit: May 24, 2004, 04:45:55 am by Gobo »