Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: tmz on September 09, 2009, 05:38:21 pm

Title: VBS Element.Stereotype updateing confusion
Post by: tmz on September 09, 2009, 05:38:21 pm
Hi,
I am writing VBS script in Excel, that exports the Elements to EA (updates existing Elements in EA to the state described in Excel, doesn't create new Elements).
I have it working for TaggedValues, so after exporting I can see the changes in TaggedValues for given Element in EA immediately. The problem is, that I would like to change Element's Stereotype too. So I wrote:
Code: [Select]
myElement.Stereotype = "application"
myElement.Update

After that I don't see any change in Elements properties in EA, BUT the change has been somewhere written, because when I run the script again and read current Stereotype of the Element (before changing), it is set to "application". But in the same time EA shows different stereotype...

Any ideas?
Title: Re: VBS Element.Stereotype updateing confusion
Post by: «Midnight» on September 09, 2009, 11:06:12 pm
If you mean that you don't see the change reflected in an open diagram, that is because you have not refreshed (or reloaded) the diagram.

Look at the various methods with names containing Reload and Refresh. Check both the Repository and Project classes.

[edit]For a better approach see Geert's post below, and the results a little further down.[/edit]
Title: Re: VBS Element.Stereotype updateing confusion
Post by: Geert Bellekens on September 10, 2009, 04:09:34 pm
Another one that I discouvered recently is the Repository.AdviseElementChange and AdviseConnectorChange.
Those work pretty good in refreshing the GUI of EA when something has changed.

Geert
Title: Re: VBS Element.Stereotype updateing confusion
Post by: Paolo F Cantoni on September 10, 2009, 04:26:54 pm
Quote
Another one that I discouvered recently is the Repository.AdviseElementChange and AdviseConnectorChange.
Those work pretty good in refreshing the GUI of EA when something has changed.

Geert
I presume that's across all open diagrams?

Paolo
Title: Re: VBS Element.Stereotype updateing confusion
Post by: Geert Bellekens on September 10, 2009, 05:23:09 pm
I'm not sure about diagrams.
I used it after updating the notes of an element.
Before I used the AdviseElementChanged the seperate notes view would not get updated when I did an element.Update().
At first I tried the Element.Refresh, but that changes the selected element in the project browser as a side effect.
AdviseElementChanged does exactly what I wanted it to do without messing with the selected item in the project browser.

Geert
Title: Re: VBS Element.Stereotype updateing confusion
Post by: tmz on September 10, 2009, 07:20:59 pm
Big thanks, the tip with advice...() function was the right one:)