Author Topic: Create autom. a Class Diagram after a new Package  (Read 19797 times)

marine1981

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Create autom. a Class Diagram after a new Package
« on: October 15, 2010, 08:17:52 pm »
Hello,
i have problem, because this is my first add-in. I write this Add-In in C#.

My problem:
After then I create a new "Package" in the "Project Browser". I want automatically create a new Class Diagram.  Someone have any idea?
I think, i need a Post-Event. But I don't know right the class or the .Net Object.
How I get the ID by the new Package?

Thanks


Sven


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13226
  • Karma: +550/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create autom. a Class Diagram after a new Pack
« Reply #1 on: October 15, 2010, 10:10:34 pm »
Sven,

Try EA_OnPostNewPackage
The info parameter contains the package id.

Geert

marine1981

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Create autom. a Class Diagram after a new Pack
« Reply #2 on: October 18, 2010, 05:15:58 pm »
Thanks Geert.  But I have a further question.
How I can create an new "Class Diagram"?

The example: Add and Manage Diagrams
...
package = m_Repository.GetPackageByID(5);
diagram = package.Diagrams.Add("Logical Diagram", "Logical");
...

I don't know the Class from the Object "package"? How I can create the Object package in C#?

Thanks

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13226
  • Karma: +550/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create autom. a Class Diagram after a new Pack
« Reply #3 on: October 18, 2010, 05:34:19 pm »
The example seems valid to me.
What do you mean by "I don't know the Class from the Object "package"?
Just look at the operation GetPackageByID. There it says that it will return an EA.Package object, so your variable "package" will need to be of the type EA.Package.

Geert

marine1981

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Create autom. a Class Diagram after a new Pack
« Reply #4 on: October 18, 2010, 05:59:27 pm »
My Example:
Code: [Select]
public virtual bool EA_OnPostNewPackage(EA.Repository Repository, EA.EventProperties Info)
{
EA.Repository Repo1;
EA.Repository TestDiagram;
Repo1 = Repository.GetPackageByID(Info)
TestDiagram = Repo1.Diagrams.AddNew("Logical Diagram","Logical");
}
I can't create a new Diagram because IntelliSense can't find "Diagrams". Where is my logical mistake?

Thanks
« Last Edit: October 18, 2010, 06:06:04 pm by marine1981 »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13226
  • Karma: +550/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create autom. a Class Diagram after a new Pack
« Reply #5 on: October 18, 2010, 06:09:16 pm »
Quote
My Example:
Code: [Select]
public virtual bool EA_OnPostNewPackage(EA.Repository Repository, EA.EventProperties Info)
{
EA.Package Repo1;
EA.Diagram TestDiagram;
Repo1 = Repository.GetPackageByID(Info)
TestDiagram = Repo1.Diagrams.AddNew("Logical Diagram","Logical");
}
I can't create a new Diagram because IntelliSense can't find "Diagrams". Where is my logical mistake?

Thanks

FTFY

Geert
« Last Edit: October 18, 2010, 06:12:59 pm by Geert.Bellekens »

marine1981

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Create autom. a Class Diagram after a new Pack
« Reply #6 on: October 18, 2010, 06:30:03 pm »
Thanks, thats helpful!

Where I can find the definitions of EA.Package, EA.Diagram ...?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13226
  • Karma: +550/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create autom. a Class Diagram after a new Pack
« Reply #7 on: October 18, 2010, 06:38:14 pm »
in the help file.

Geert

marine1981

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Create autom. a Class Diagram after a new Pack
« Reply #8 on: October 18, 2010, 10:09:28 pm »
Which helpfile do you mean?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13226
  • Karma: +550/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create autom. a Class Diagram after a new Pack
« Reply #9 on: October 18, 2010, 10:53:02 pm »
the EA help, as in RTFM  ;)

Geert

marine1981

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Create autom. a Class Diagram after a new Pack
« Reply #10 on: October 18, 2010, 11:44:45 pm »
EA Help = SDK?
I never find the EA.Package, EA.Diagram, ...  there(I used the search from Acrobat Reader).
I search a Overview with all Classes und a small description on one letter. Do you know somethink like this one?


Thanks and excause me but this is my first Micro-Add-In.
« Last Edit: October 18, 2010, 11:47:22 pm by marine1981 »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13226
  • Karma: +550/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create autom. a Class Diagram after a new Pack
« Reply #11 on: October 18, 2010, 11:59:48 pm »
Yep,

Search for "Repository" and select the second result. (Repository) If you then go to the Contents tab you'll see all the API classes and their documentation.

Geert

marine1981

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Create autom. a Class Diagram after a new Pack
« Reply #12 on: October 20, 2010, 06:25:19 pm »
Overview on Page 189 in the SDK. :)

But now I have other question.
How I get the ID from the new Package.
Quote
public virtual bool EA_OnPostNewPackage(EA.Repository Repository, EA.EventProperties Info)
Which function do I need? My Idea was:
Code: [Select]
public virtual bool EA_OnPostNewPackage(EA.Repository Repository, EA.EventProperties Info)
{
EA.Package Repo1;
EA.Diagram TestDiagram;
Repo1 = Repository.GetPackageByID(Info/*It's false, because a object*/)
TestDiagram = Repo1.Diagrams.AddNew("Logical Diagram","Logical");
}

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13226
  • Karma: +550/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create autom. a Class Diagram after a new Pack
« Reply #13 on: October 20, 2010, 06:39:42 pm »
From TFM on EA_OnPostNewPackage
Quote
Info
 EA.EventProperties
 IN
 Contains the following EventProperty objects for the new package:
PackageID: A long value corresponding to Package.PackageID.  

From TFM on EventProperties:
Quote
Get (object Index)
 EventProperty
 Read only. Returns an EventProperty in the list, raising an error if Index is out of range.

Parameters:

Index: Variant - can either be a number representing a zero-based index into the array, or a string representing the name of the EventProperty. For example, Props.Get(3) or Props.Get("ObjectID").  
So I guess you'll have to do something like
Code: [Select]
info.Get("PackageID")to get the packageID.

Geert

marine1981

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Create autom. a Class Diagram after a new Pack
« Reply #14 on: October 21, 2010, 05:57:47 pm »
Thats right!
But Info.Get("PackageID") does not work.
I have got a understanding problem with the method get(object Index).
How I use the method Get()?
The example Probs.Get(3) or Probs.Get("Objetct ID").
Is the number 3 equivalent with "ObjectID"?
Is ObjectID a variable, string or an enumeration?
« Last Edit: October 22, 2010, 05:26:18 pm by marine1981 »