Author Topic: Create a composite diagram  (Read 5356 times)

Pedro

  • EA Novice
  • *
  • Posts: 15
  • Karma: +0/-0
    • View Profile
Create a composite diagram
« 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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create a composite diagram
« Reply #1 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

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Create a composite diagram
« Reply #2 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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create a composite diagram
« Reply #3 on: June 26, 2013, 06:37:13 pm »
Aaron,

IsComposite is documented as being read-only  :-/

Is the documentation wrong?

Geert

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Create a composite diagram
« Reply #4 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

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create a composite diagram
« Reply #5 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
« Last Edit: June 27, 2013, 04:43:56 pm by Geert.Bellekens »

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Create a composite diagram
« Reply #6 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...
Best Regards, Roy

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Create a composite diagram
« Reply #7 on: June 28, 2013, 12:13:09 am »
Gesundheit!