Sunteți pe pagina 1din 4

How to Create EA Addin for Version 11.

0 on Windows 8 and 7
(.Net -> C#)
0 - Run Visual Studio As Administrator (Must on windows 8 and 7)

1- Create a Dll project form visual studio.


2- In project, delete the default class.
3-Take Template Class given with this Guide.
4-Include That template class in your project.
5-Rename the Class’s File and the Class name inside the file (Must be same).
6- Rename the namespace According to the default namespace of your project (Usually it’s the
name of your project in visual studio. They must be same)
7-add reference to the introp.EA.dll from the EA installation folder.
8-add reference to system.windows.forms.
9- Go to the project properties ->application Settings -> click on Assembly info Button .Tick
“Make assembly Visible-COM”
10- Go to the Project Properties ->Build . Scroll Down and Tick “Register for COM Introp”
11- Save Your project by pressing ctrl+S select “Release from Build menu” and Build it.
– Adding the registry value so that EA could know about your Addin
12- Run Regedit.exe as administrator from “Run”
13- Navigate to “ HKEY_CURRENT_USER\Software\Sparx Systems\EAAddins”
14 – if you don’t find “EAAddins” key under the “Sparx Systems” then go ahead and create it
with the name “EAAddins” or Use this command inside “RUN” regedit
HKEY_CURRENT_USER\Software\Sparx Systems\EAAddins
15 –After Conforming the EAAddins key select it and right click on it and select add -> key
16 – Name the new key exactly as the name of your project or (Name of namespace)
17-Now Select Your newly added key look on the right side of registery editor (in Values pane
Where a Default value key will be available )
18 – Double click Default value key and change value to something like
nameOfYourProject.NameOfyourClass (Pay full attention here)
19 -Save it and refresh registry editor
20 – Fire up EA and look under the extension Manu your newly created add in is waiting here. 

Register your dell from some other place.


C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe "D:\EAAdin\EAPtest.dll"
/codebase
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe "D:\EAAdin\TEST3.dll"
/codebase
Notes – version of Framework does not matter (I have tested it by creating addin with every
version )
Template Class
Credits to (Geert Bellekens)

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace BEST
{
public class ad
{

// define menu constants


const string menuHeader = "-&BalwalAddin";
const string menuHello = "&Hello Comsats";
const string menuGoodbye = "&Good By Comsats";

private bool shouldWeSayHello = true;

/// <summary>
/// Called Before EA starts to check Add-In Exists
/// Nothing is done here.
/// This operation needs to exists for the addin to work
/// </summary>
/// <param name="Repository">the EA repository</param>
/// <returns>a string</returns>

public String EA_Connect(EA.Repository Repository)


{
//No special processing required.
return "a string";
}

/// <summary>
/// Called when user Clicks Add-Ins Menu item from within EA.
/// Populates the Menu with our desired selections.
/// Location can be "TreeView" "MainMenu" or "Diagram".
/// </summary>
/// <param name="Repository">the repository</param>
/// <param name="Location">the location of the menu</param>
/// <param name="MenuName">the name of the menu</param>
/// <returns></returns>
public object EA_GetMenuItems(EA.Repository Repository, string Location,
string MenuName)
{

switch (MenuName)
{
// defines the top level menu option
case "":
return menuHeader;
// defines the submenu options
case menuHeader:
string[] subMenus = { menuHello, menuGoodbye };
return subMenus;
}
return "";
}

/// <summary>
/// returns true if a project is currently opened
/// </summary>
/// <param name="Repository">the repository</param>
/// <returns>true if a project is opened in EA</returns>
bool IsProjectOpen(EA.Repository Repository)
{
try
{
EA.Collection c = Repository.Models;
return true;
}
catch
{
return false;
}
}

/// <summary>
/// Called once Menu has been opened to see what menu items should active.
/// </summary>
/// <param name="Repository">the repository</param>
/// <param name="Location">the location of the menu</param>
/// <param name="MenuName">the name of the menu</param>
/// <param name="ItemName">the name of the menu item</param>
/// <param name="IsEnabled">boolean indicating whethe the menu item is
enabled</param>
/// <param name="IsChecked">boolean indicating whether the menu
ischecked</param>
public void EA_GetMenuState(EA. Repository Repository, string Location, string
MenuName, string ItemName, ref bool IsEnabled, ref bool IsChecked)
{
if (IsProjectOpen(Repository))
{
switch (ItemName)
{
// define the state of the hello menu option
case menuHello:
IsEnabled = shouldWeSayHello;
break;
// define the state of the goodbye menu option
case menuGoodbye:
IsEnabled = !shouldWeSayHello;
break;
// there shouldn't be any other, but just in case disable it.
default:
IsEnabled = false;
break;
}
}
else
{
// If no open project, disable all menu options
IsEnabled = false;
}
}
/// <summary>
/// Called when user makes a selection in the menu.
/// This is your main exit point to the rest of your Add-in
/// </summary>
/// <param name="Repository">the repository</param>
/// <param name="Location">the location of the menu</param>
/// <param name="MenuName">the name of the menu</param>
/// <param name="ItemName">the name of the selected menu item</param>
public void EA_MenuClick(EA. Repository Repository, string Location,
string
MenuName, string ItemName)
{
switch (ItemName)
{
// user has clicked the menuHello menu option
case menuHello:
this.sayHello();
break;
// user has clicked the menuGoodbye menu option
case menuGoodbye:
this.sayGoodbye();
break;
}
}

/// <summary>
/// Say Hello to the world
/// </summary>
private void sayHello()
{
MessageBox.Show("Hello World");
this.shouldWeSayHello = false;
}

private void sayGoodbye()


{
MessageBox.Show("Goodbye World");
this.shouldWeSayHello = true;
}

/// <summary>
/// EA calls this operation when it exists. Can be used to do some
cleanu work.
/// </summary>
public void EA_Disconnect()
{
GC.Collect();
GC.WaitForPendingFinalizers();
}

}}

S-ar putea să vă placă și