Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Jenni on January 20, 2020, 11:34:07 pm
-
Hello,
I have a function in my add-in (C#, EA version 12.0) that automatically inserts a diagram notes element in every newly created diagram. I am using the function EA_OnPostNewDiagram to get notified.
Now, when the user copies an existing diagram via project browser the function EA_OnPostNewDiagram is executed as well. Thus the new diagram contains two overlaying diagram notes elements. That's a problem for our QC.
While copying a diagram EA_OnPostNewDiagram is called before the diagram objects are inserted. So it is not possible to check whether the copied diagram already contains a diagram notes element.
How can I prevent the duplicate diagram notes? Is there a way to find out, whether the user is creating a new diagram or copying an existing one?
Thank you.
Jenni
-
Hi Jenni, and welcome to the forum.
As far as I can tell I don't think there's a way to detect diagram copying as opposed to "from-scratch" creation.
Possibly you could move your note creation to EA_OnPostOpenDiagram or EA_OnPostCloseDiagram. While diagrams need not be automatically opened upon creation, you do need to open them to add things to them, which means that any note-less diagrams should be completely empty. Perhaps that's an acceptable limitation.
HTH,
/Uffe
-
Why not lookup t_diagramobjects whether or not your note is already present?
q.
-
Hi Uffe,
EA_OnPostOpenDiagram has the same problem. The new diagram is still empty when the event is fired.
But you gave me an idea: While copying a diagram OnPostNewDiagram is fired before OnPostOpenDiagram. While creating a new diagram from-scratch the events are fired in reverse order. So I start a timer in OnPostNewDiagram to suppress insertion the diagram notes element for one or two seconds. Thats not a perfect workaround, but it works.
Thanks for your suggestions.
Jenni