Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: A. Engle on August 16, 2014, 02:24:13 am
-
I'm creating a model (package), a package within that model, a diagram within that package and elements within THAT package all with my C# based add-in. I'm obviously executing the right Updates and Refreshes. I'm even able to get tagged values on the element, as well as create a scenario on the element and steps on the scenario.
But I cannot get the element on to the Diagram to save my life! I also can't find any (up-to-date/relevant/c# based) examples online.
When I open the .eap file after my add-in completes and open the diagram, it's blank/empty/barren of all elements.
So what is the process?
-
You need to create DiagramObjects for the desired diagram. Once created you need to link the objectId. From my Scripting book:
dia_obj = diagram.DiagramObjects.AddNew ("l=10;r=110;t=-20;b=-80", "");
dia_obj.ElementID = element.ElementID;
dia_obj.Update ();
Repository.ReloadDiagram (diagram.PackageID);
q.
-
AHA! Linking the DO to the Element...that makes sense!
Do I need to do the ReloadDiagram? I'm currently doing: diagram.DiagramObjects.Refresh() and diagram.Update()?
which is the 'more preferred' method or is there a reason for one or the other?
Thanks qwerty! glad I could give you another opportunity to plug yer book! ;)
-
lol
The Update is to finalize the creation. So you don't need diagram.update as the diagram is already there. The Refresh is only needed if you want to iterate the collection afterwards which is usually not the case (you just created the objects and know about them). The Reload finally will trigger EA to draw the diagram anew. EA is laze (for a good reason) and only when you're done updating you call it once to give the user a fresh view.
q.
-
Works like a charm. Thanks again!