Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Pedro on June 25, 2013, 12:41:30 am

Title: Create a composite diagram
Post by: Pedro on June 25, 2013, 12:41:30 am
I have the following code, which works creating a diagram:

Code: [Select]
 private static void CreateDiagram(string _name, Package _root)
        {
            var tmp = (Diagram)null;

            try
            {
                tmp = _root.Diagrams.GetByName(_name);
            }
            catch
            {
            }

            if (tmp == null)
            {
                tmp = _root.Diagrams.AddNew(_name, "Component");

                tmp.HighlightImports = false;
                tmp.Update();

                _root.Diagrams.Refresh();

                _root.Update();
                _root.Diagrams.Refresh();
            }

            ///The diagram already exists, and we do not create it. (Empty else)
        }

HOW can I make it composite? Please, this is extreme easy in the in EA but looks impossible for me in my addin code.
Title: Re: Create a composite diagram
Post by: Geert Bellekens on June 25, 2013, 03:34:39 pm
There are a few post from a long time ago that explain how to do it.
Use the top left search button and search for "composite".

Geert
Title: Re: Create a composite diagram
Post by: Aaron B on June 26, 2013, 09:48:44 am
See IsComposite on the Element Class:
http://www.sparxsystems.com/enterprise_architect_user_guide/10/automation_and_scripting/element2.html

If your element already contains a diagram, setting IsComposite = true will link to the existing sub diagram.

You code sample seems to be adding a diagram to a Package though - you do not need to set a Package as Composite.  Double-clicking on a Package within a diagram should automatically open it's sub diagram anyway.
Title: Re: Create a composite diagram
Post by: Geert Bellekens on June 26, 2013, 06:37:13 pm
Aaron,

IsComposite is documented as being read-only  :-/

Is the documentation wrong?

Geert
Title: Re: Create a composite diagram
Post by: Aaron B on June 27, 2013, 11:24:07 am
IsComposite is Read/Write.  Maybe you are getting confused with CompositeDiagram, which is read only.
http://www.sparxsystems.com/enterprise_architect_user_guide/10/automation_and_scripting/element2.html
Title: Re: Create a composite diagram
Post by: Geert Bellekens on June 27, 2013, 03:50:27 pm
Quote
IsComposite is Read/Write.  Maybe you are getting confused with CompositeDiagram, which is read only.
http://www.sparxsystems.com/enterprise_architect_user_guide/10/automation_and_scripting/element2.html

True, by [highlight]my[/highlight] bad :-[

Geert
Title: Re: Create a composite diagram
Post by: RoyC on June 27, 2013, 04:37:47 pm
True, by bad

These computer people who work too intently on their programs - they are always getting a code in the nose...
Title: Re: Create a composite diagram
Post by: qwerty on June 28, 2013, 12:13:09 am
Gesundheit!