Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Pedro on June 25, 2013, 12:41:30 am
-
I have the following code, which works creating a diagram:
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.
-
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
-
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.
-
Aaron,
IsComposite is documented as being read-only :-/
Is the documentation wrong?
Geert
-
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
-
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
-
True, by bad
These computer people who work too intently on their programs - they are always getting a code in the nose...
-
Gesundheit!