Book a Demo

Show Posts

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.


Messages - Kai H.

Pages: [1]
1
thank you! I will post code after implementation :)

2
Good Morning,

I want to generate an SysML Internal Block Diagram that is looking like the one that appears, if one click on a Block in a SysML Block Definition Diagram and select "make composite". It is a little weird to describe that, so I post here the link to a screenshot:

http://khfg.de/public/supportanfrage.pdf

The pictures have a little german, but it is basically that what is described above, but the last red text is important, it says : "... and for that, the code is missing"  ;)

Thanks for your reply!

Kai

3
This is not a question, but an answer from the EA support. I post it here to share it with you.

The folowing code creates a composite aggregation with the black diamond :

Code: [Select]
EA.Connector CompositeConnector = (EA.Connector)destElement.Connectors.AddNew("", "Aggregation");
CompositeConnector.SupplierEnd.Aggregation = 2;
CompositeConnector.ClientID = Composite.ElementID;
CompositeConnector.SupplierID = destElement.ElementID;
CompositeConnector.Update();

to have the white diamond (shared),
Code: [Select]
CompositeConnector.SupplierEnd.Aggregation = 2;has to be replaced by:
Code: [Select]
CompositeConnector.SupplierEnd.Aggregation = 1;or by zero for none.

Kai

4
Automation Interface, Add-Ins and Tools / Re: Preserve Add-In Objects
« on: March 29, 2011, 06:57:07 pm »
Thanks Geert,

i tried it and it's working fine, here is my code:

Code: [Select]
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;
            }
            }
      }
}

Cheers

Kai

5
Automation Interface, Add-Ins and Tools / Re: Preserve Add-In Objects
« on: March 25, 2011, 05:45:14 pm »
Thank you for your replies, I think I will use serialization, since then I have the required object available after exit. For future forum searches, below are two nice howto links

to store C# objects to XML file using serialization:
http://www.switchonthecode.com/tutorials/csharp-tutorial-serialize-objects-to-a-file
http://www.devx.com/tips/Tip/39593

Kai

6
Automation Interface, Add-Ins and Tools / Re: Preserve Add-In Objects
« on: March 24, 2011, 11:33:12 pm »
Thanks for your answer. Unfortunately, this sounds equally bad  :(

7
Automation Interface, Add-Ins and Tools / Preserve Add-In Objects
« on: March 24, 2011, 07:43:15 pm »
Good morning,

I searched the forum and also asked some colleaugues but noone came up with an answer to this problem:

During the control flow of my Add-In, I create a large object from file. After the Add-In has executed, I loose the control flow and the object gets destroyed. This results in creating the same object over and over again, every time the user selects other actions from my Add-In. so here is my question:


How can I preserve objects that an Add-In created for later use?


Cheers and thanks for your reply  ;)

Kai

8
Thank you stao, it works fine!

Another hint: if you want to add a TaggedValue after you created the connector, remember to call the Update() function on the connector before you add the TaggedValue, otherwise it will not appear in EA. A second Update() of the connector after the TaggedValue is inserted is not neccessary:

Code: [Select]
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();

Kai

9
Hi,

here is some working code for adding a new TaggedValue to an Element:

Code: [Select]
EA.TaggedValue b = (EA.TaggedValue)portElem.TaggedValues.AddNew("myRate", "TaggedValue");
b.Value = "0.1";
b.Update();

But the same code is not working for Connectors:

Code: [Select]
EA.TaggedValue tv = (EA.TaggedValue)connector.TaggedValues.AddNew("myName", "TaggedValue");
tv.Value = "myValue";
tv.Update();

Surprisingly, this results in the following exception:

Code: [Select]
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

Any ideas?

Cheers

Kai

Pages: [1]