Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: RainerQ on November 06, 2010, 12:10:44 am

Title: How to move DiagramObjects
Post by: RainerQ on November 06, 2010, 12:10:44 am
Hi

I would like to move a couple of diagram objects on a diagram
My attempt to do so looks as follows:

private static void MakeRoom(Diagram diagram, Rectangle rect)
{
    DiagramObject[] objectsToMove = (from DiagramObject dgobj in diagram.DiagramObjects
                                        where dgobj.left < rect.Right
                                        select dgobj).ToArray();

    foreach (DiagramObject dgObject in objectsToMove)
    {
        dgObject.top -= rect.Height + 10;
        dgObject.bottom -= rect.Height + 10;
        dgObject.Update();                
    }
    diagram.Update();
}

In my case I receive 3 diagram object as a result of the LINQ statement, but changing top and buttom properties of them does not result in a move on the diagram.

What is wrong with my code?

Thanks for help and hints.

Regards
Rainer
Title: Re: How to move DiagramObjects
Post by: stao on November 06, 2010, 08:31:23 am
do you reload the diagram?
like this:
repository.ReloadDiagram(actDiag.DiagramID);

stao
Title: Re: How to move DiagramObjects
Post by: RainerQ on November 06, 2010, 06:13:06 pm
Hi Stao,

thanks for the hint. That was it.

Regards
Rainer
Title: Re: How to move DiagramObjects
Post by: mrf on November 08, 2010, 09:18:33 am
The dependancy on reloading the diagram to see the changes made to diagram objects should hopefully be removed in the next major release. Diagram Objects will have their style and position automatically applied in the UI when Update() is called on the DiagramObject object.
Title: Re: How to move DiagramObjects
Post by: Geert Bellekens on November 08, 2010, 05:27:26 pm
That would be a nice improvement.

Geert
Title: Re: How to move DiagramObjects
Post by: RainerQ on November 08, 2010, 08:14:05 pm
Yes, that would be great!

Regards
Rainer