Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Nick on February 02, 2005, 05:16:31 am

Title: Problems working with diagrams from Addin
Post by: Nick on February 02, 2005, 05:16:31 am
I would like to change the colour of a connector on a diagram using an EA Addin.

I have been able to change the colour of an element by adding "BCol=35723;BFol=9342520;" to the 'Style' property of the DiagramObject. (does anyone know where the colour values come from? I copied these from the help file).  Having done this though, I don't seem to be able to subsequently change the colour through the user interface.

However, when I add the same values to the 'Style' property of the DiagramLink object, there is no effect.

Am I doing this the in the correct way?

Thanks
Title: Re: Problems working with diagrams from Addin
Post by: KP on February 02, 2005, 02:15:46 pm
You need to change the value of the Connector.Color field. Unfortunately, this will change the appearance of the connector on ALL diagrams - it's on our list of things to fix...

A search for "t_connector" should take you to the page in the help file.
Title: Re: Problems working with diagrams from Addin
Post by: Nick on February 03, 2005, 05:55:41 am
Thanks for your reply,

I have tried the Connector.Color property but the new connector still displays as black.

Here is the code I have tried (C#)

'connector' in this example is an existing Connector on this Element

Connector testCon = connectors.AddNew("", "StateFlow") as Connector;
                    testCon.Color = 255;
                    testCon.Width = 3;
                    testCon.SupplierID = connector.SupplierID;
                    testCon.Stereotype = "test";
                    testCon.Update();
repository.ReloadDiagram(d.DiagramID)


I am running EA version 4.10.730 if that makes a difference. I did upgrade to the latest version, but my addin wouldn't even display in the Addin menu because a number of the addin events stopped firing, including EA_GetMenuItems(), so I had to roll back.

The Connector is added to the Element and displays on the diagram but the colour and width are the defaults.

If I change the colour and Width throught the UI, I can see that the values have been entered in the t_Connector table LineColor and IsBold fields but if I add code to report the value of Connector.Color and Width, the value 0 is always returned.

If I set the values directly in the t_connector table, it has the desired effect on the Connector.

Other questions;

I can set the stereotype of the connector, as above, but the attached stereotype label does not appear on the diagram as it does if you do it through the UI.  Again I can see the entry in the t_connector table but can it be added via code.

I have noticed that the Repository.ReloadDiagram() and Repository.CloseDiagram() methods have no effect if the diagram in question is the only open diagram or it is the first open diagram in the tab order of open diagrams.  Is this a known problem or is it just me.

Thanks

                 
Title: Re: Problems working with diagrams from Addin
Post by: charge on February 07, 2005, 06:14:30 am
Nick,

You should try this using the latest version. Up from EA 4.5 you have to change your project references to the  Interop.EA.dll from EA and then it works fine. You can find this file on C:\Program Files\Sparx Systems\EA\Interop.EA.dll

The Q&D way is to change the values in de datafile (you can open EA as a Access MDB and then change de values)

Peter.
Title: Re: Problems working with diagrams from Addin
Post by: Nick on February 08, 2005, 02:16:22 am
Hi Peter,

Thanks for your reply.

When I first upgraded, I did try re-adding the reference to EA as per the instructions in the help file but without success, i.e.

Microsoft C#

1. Select Enterprise Architect Object Model 2.0 from the list. (If this does not appear, go to the command line and re-register EA using ea.exe /unregister then ea.exe /register).

2. Create a new Windows Application project.  

3. From the Solution Explorer, right-click on References and select Add References from the menu.  

4. Click the COM tab.  

5. Click the button Select then OK.  


This time, however, I browsed directly to the interop dll instead of choosing from the list of Com objects and everything is working, including the colour and width properties, although I think I will need to add an entry directly to the t_Connector table to get the connector stereotype label on the diagram.

Many thanks

Nick