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 - IanG

Pages: [1]
1
Automation Interface, Add-Ins and Tools / Positioning embedded elements
« on: September 22, 2018, 01:12:51 am »
Hello,

I'm sure this is a simple fix but I've not been able to figure it out.

I want to be able to position ports on blocks using the C# sdk.
I'm assuming it is done by using different values for the left, right, top, bottom properties of the EA.Element object.



However, I've tried dozens of combinations of values but I can only move the port a few pixels down on the left side or to the top left hand corner.
I have a feeling that the left, right, top, bottom properties are for positioning the element and not the port but they are the only properties that have any effect.
(albeit, one of two positions regardless of what int is passed to them.)

Can someone see where I'm going wrong or point me in the right direction?


Code: [Select]
//CREATE LOGICAL ELEMENT AND DIAGRAM OBJECT
                    EA.Element NewElement = (EA.Element)packageToEnrich.Elements.AddNew(breakdownElement.names[0].text, "Class");
                    NewElement.MetaType = "Block";
                    NewElement.Stereotype = "Block";

                    EA.DiagramObject DiagOb = (EA.DiagramObject)NewDiagram.DiagramObjects.AddNew(ElementPlacer.GetNextElement(), "");
                    DiagOb.ElementID = NewElement.ElementID;     
                    DiagOb.Update();           

                    foreach (InterfacePortInstance IFPI in PortsOnElement)
                    {
                            EA.Element embdElement = (EA.Element)NewElement.EmbeddedElements.AddNew(IFPI.ID, "Port");
                            embdElement.MetaType = "FlowPort";                                                                                                 
                            embdElement.Update();                 

                            EA.DiagramObject DiaPort = (EA.DiagramObject)NewDiagram.DiagramObjects.AddNew("", "");
                            DiaPort.ElementID = embdElement.ElementID;

                        DiaPort.left = 10;
                        DiaPort.right = 10;
                        DiaPort.top = 0;
                        DiaPort.bottom = 0;                     

                        DiaPort.Update();                                                             
                    }




These are what my elements look like.



2
Indeed,

But the 16bit constraint is not one I've made, it's how the Enterprise Architect SDK is setup.
The Models.GetAt() method takes a short to represent the ID. It won't accept any other type, ushort, long, int etc.



I can get at the data as xml with an SQL command but I want to be able to retrieve the EA package object.

Cheers,
Ian


3
The model doesn't have more than 41,000 models but the ID numbers definitely exceed 32767.
I'm working with a copy of  a live eap file that has had the majority of the content removed.

I've uploaded a screen shot with the contents of the diagramobjects table so you can see.


I'm assuming that with elements being deleted and created over time has inflated the ID number. But that's only a guess, I'm not sure why that should be.

I can't do a for loop since and look for a match either since it's not enumerable. Hmmmmm

4
Hello,

I'm writing an extension for EA in C# using.

Normally, when I want to access a model in the repository I use the following:
Code: [Select]
EA.Package MyPackage = (EA.Package)m_Repository.Models.GetAt(MyShort);

However, the the repository I'm working with has over 41,000 models.
The GetAt method only takes a short which is a problem since shorts are 16bit and only go to 32767. (unsigned shorts don't work.)

Has anyone else come across this problem and know of a solution?

Cheers,

Ian 

5
Hello,

I'm looking to export models from EA into XMI using C#.

From the SDK documentation I assume that using the ExportPackageXMI would be the way to do it but I'm not sure how to do it.
Could someone provide or point me towards an example?

Cheers,
Ian

6
Hi,

Thanks for the quick responses! I did already create separate profiles for each toolbox and it didn't work. Out of desperation I upgraded my version of EA to 12.1 from 12.0 and magically it worked! Might have been a bug..?

Geert, I just want to say thanks for your presentation at the EA user group meeting in Munich at Airbus last year. You showed us how to make an EA addin in ten minutes. I found that very useful!!

Many thanks,
Ian


7
Hello,

I'm trying to create a set of custom diagram profiles each with their own toolbox. I'm starting from the ecoSystem example with the MDG Profile helper and that deploys fine.
However, when I deploy an MDG file with more than one diagram with their own toolboxes I run into trouble.
When I create an instance of my custom diagram one of two things happen. i) Every tool box shows up for each diagram. ii) the correct toolbox shows up for one diagram, but not the second.

When creating the MDG: Should I create a separate profile for and every toolbox and diagram or should I be looking to create separate class diagrams under each profile. Maybe I can create lots of stereotypes on one diagram. I've been trying everything but nothing works.

Any tips would be greatly received.

Kind Regards.

Ian



8
Excellent - that works great! :)
Thank you both so much for your help.

Cheers,
Ian

9
Hello all,

I'm trying to build an add-in which allows the user to create a tagged value through a windows form. The user selects the package and then the element which will have the next tagged value.

The code compiles fine, EA and the add-in run fine but the new tagged value simply does get added. Can anyone see anything wrong in my approach? I've played around with the refresh and the update but no luck so

Thanks in advance.

Ian




            string SelectedElement = treeEA.SelectedNode.Text;      

            EA.Package aPackage;
            aPackage = EA_Repository.GetTreeSelectedPackage();


            foreach (EA.Package thePackage in aPackage.Packages)
            {

                foreach (EA.Element theElements in thePackage.Elements)
                {

                    if (SelectedElement == theElements.Name)
                    {      
                        theElements.TaggedValues.AddNew("MyTagName", "MyTagValue");
                        theElements.TaggedValues.Refresh();
                        theElements.Update();

                          
                    
                    }
                }
          
                 }

        


Pages: [1]