1
Automation Interface, Add-Ins and Tools / Re: SysML Internal Block Diagrams
« on: April 14, 2011, 11:04:00 pm »
thank you! I will post code after implementation

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
EA.Connector CompositeConnector = (EA.Connector)destElement.Connectors.AddNew("", "Aggregation");
CompositeConnector.SupplierEnd.Aggregation = 2;
CompositeConnector.ClientID = Composite.ElementID;
CompositeConnector.SupplierID = destElement.ElementID;
CompositeConnector.Update();
CompositeConnector.SupplierEnd.Aggregation = 2;
has to be replaced by:CompositeConnector.SupplierEnd.Aggregation = 1;
or by zero for none.using System;
using System.Windows.Forms;
namespace EA_Banana_AddIn
{
public class Main
{
private bool m_ShowFullMenus = false;
private bool banana = false;
public String EA_Connect(EA.Repository Repository)
{
this.banana = true;
//No special processing required.
return "a string";
}
//Called when user Click Add-Ins Menu item from within EA.
//Populates the Menu with our desired selections.
public object EA_GetMenuItems(EA.Repository Repository, string Location, string MenuName)
{
EA.Package aPackage = Repository.GetTreeSelectedPackage();
switch( MenuName )
{
case "":
return "-&Banana";
case "-&Banana":
string[] ar = {"Banana Test"};
return ar;
}
return "";
}
//Sets the state of the menu depending if there is an active project or not
bool IsProjectOpen(EA.Repository Repository)
{
try
{
EA.Collection c = Repository.Models;
return true;
}
catch
{
return false;
}
}
//Called once Menu has been opened to see what menu items are active.
public void EA_GetMenuState(EA.Repository Repository, string Location, string MenuName, string ItemName, ref bool IsEnabled, ref bool IsChecked)
{
if( IsProjectOpen(Repository) )
{
if( ItemName == "Menu1" )
IsChecked = m_ShowFullMenus;
else if( ItemName == "Menu2")
IsEnabled = m_ShowFullMenus;
}
else
// If no open project, disable all menu options
IsEnabled = false;
}
//Called when user makes a selection in the menu.
//This is your main exit point to the rest of your Add-in
public void EA_MenuClick(EA.Repository Repository, string Location, string MenuName, string ItemName)
{
switch (ItemName)
{
case "Banana Test":
MessageBox.Show("It's "+this.banana+" that bananas are tasteful.", "Hint", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
break;
}
}
}
}
EA.Connector connector = (EA.Connector)sourceElement.Connectors.AddNew("Connector", "Connector");
connector.ClientID = sourceElement.ElementID;
connector.SupplierID = destinationElement.ElementID;
connector.Update();
EA.ConnectorTag tv = (EA.ConnectorTag)connector.TaggedValues.AddNew("myName", "TaggedValue");
tv.Value = "myValue";
tv.Update();
EA.TaggedValue b = (EA.TaggedValue)portElem.TaggedValues.AddNew("myRate", "TaggedValue");
b.Value = "0.1";
b.Update();
EA.TaggedValue tv = (EA.TaggedValue)connector.TaggedValues.AddNew("myName", "TaggedValue");
tv.Value = "myValue";
tv.Update();
System.InvalidCastException was unhandled by user code
Message=Unable to cast COM object of type 'System.__ComObject' to interface type 'EA.TaggedValue'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{EF08950B-949E-435F-84A3-A59E3106C3BF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Source=Anonymously Hosted DynamicMethods Assembly