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

Pages: [1]
1
Hi Geert,
Of course I use the embeddedElements collection. But I need the port reference to add them to the embeddedElements collection and I don´t know how to have this port reference. I write the AddIn in C# and I don´t know the fonction Repository.Execute(SQLstring).
Manually I use "Add EmbeddedElements" to add port reference to an instance, but in C# I don´t how do to that.

Regards

Patjoe

2
Hallo,

I have the following problem and hope somebody could help me.
using AI I have create a class element "element1" that containt an embedded element "port1".
I have create a instance of element1 (element1Instance) and I want to add reference of port1(port1Ref) into element1Instance.
I want to create a new port and set it as reference to port1
I know that port1Ref.MiscData[2] = port1.elementGUID, but the problem is that I cannot set the MiscData[2] of an element.

I will very thankful when somebody can help me

Patjoe

3
Hi Simon,
I have already found it. At first time I used a "Class"-Type therefore it could not work. I have change it to a "Object"-Type and it is work properly now.
Thank for your reply.
Patson

4
Hi,
I developpe Add-Ins for Enterprise Architect in C# and I have the following problem.
I want to add the instance of an existing element in a new created diagram.
I have already created the diagram and I can add an element to the diagram using the collectionDiagramObjects and setting the diagramObjects with the elementID of the existing element.
But to add an instance I have to create it and I don´t know how to do that.

I thought that the ClassifierID of an element "element2" is the elementID of an element "element1"  if element2 is an instance of element1.
But when I add an element2 in the package and set it ClassifierID attribut with the elementID of element1 and then apply update on element2, element2 does not have the symbol of an instance and does not behave as a instance.

I will be very thankful if somebody can help me.

Patson

5
Hi Martin,

it work with the sequence attribut of diagramObject. The element to be fix must have a lower Sequence value.

Thanks for the Help
Regards

Joe

6
Hi all,
I am working on add-in and I have to do the following.
first I have to select an element (element1 from type Class) from a project browser and create a subdiagram ("NewDiagram") to this element. Then I have to copy a link to  "element1" into the subdiagram. so far it is good.
secondly I have to create a new element (element2 from type Class) and add them into "NewDiagram" such that "element2" is always in front of(also it is fix to ) "element1" when moving "element1" in the diagram.
Manually the second element is automatically in front of the first element or it can be do by applying Z-Order -> Bring forward to "element2". But when I do it with the Automation Interface, "element1" is always fix to "element2" although I want to have the contrary.
I will be very grateful when someboy can help me

Regards

my code

                    EA.ObjectType obt = Repository.GetTreeSelectedItemType();
                    if(obt != ObjectType.otElement)
                    {
                        MessageBox.Show("Please select an element in the project browser");
                        return;
                    }

                    Object obj = Repository.GetTreeSelectedObject();
                    EA.Element element1 = (EA.Element)obj;

                    // attach a subdiagram to the selected element
                    EA.Collection collectionSubDiag = element1.Diagrams;
                    Object obj3 = collectionSubDiag.AddNew("NewDiagram", "Logical");
                    EA.Diagram diagram = (EA.Diagram)obj3;
                    diagram.Update();
                    collectionSubDiag.Refresh();

                    // create a link to the selected element in NewDiagram.
                    EA.Collection collectionDiagramObjects = diagram.DiagramObjects;

                    Object obj5 = collectionDiagramObjects.AddNew("", "");
                    EA.DiagramObject dobj5 = (EA.DiagramObject)obj5;
                    dobj5.ElementID = element1.ElementID;
                    dobj5.Update();
                    collectionDiagramObjects.Refresh();

                    Repository.RefreshOpenDiagrams(true);
                    Repository.ReloadDiagram(diagram.DiagramID);
                    Repository.OpenDiagram(diagram.DiagramID);

                    // create a new element "element2" and add it to "NewDiagram" such that
                    // "element2" is always fix (in front) to "element1" when moving "element1"
                    // manually it is do with Z-order -> Bring forward.

                    EA.Collection collectionChildElem = element1.Elements;
                    Object obj2 = collectionChildElem.AddNew("newElement", "Class");
                    EA.Element element2 = (EA.Element)obj2;
                    element2.ParentID = element1.ElementID;
                    element2.Stereotype = "Failure";
                    element2.Update();
                    collectionChildElem.Refresh();

                    // Add "element2" to "NewDiagram"
                    Object obj4 = collectionDiagramObjects.AddNew("", "");
                    EA.DiagramObject dobj4 = (EA.DiagramObject)obj4;
                    dobj4.ElementID = element2.ElementID;
                    dobj4.Update();
                    collectionDiagramObjects.Refresh();


                    Repository.RefreshOpenDiagrams(true);
                    Repository.ReloadDiagram(diagram.DiagramID);
                    Repository.OpenDiagram(diagram.DiagramID);

7
I have found it.
When I have to add an existing element in a new diagram and then change the size of this element in the diagram, I have to change at first the size of the existing element before adding it to the collectionDiagramObjects.
Thanks for our Help
pat

8
Hi,
Thanks for the answer. I do the same things as Magnus but it does´nt work.
After the execution the both class joeClass1 and joeClass2 appear at the same position in the diagram view. I want to change the size of one class.

Here is my code in C#.


                    Object obj2 = collectionElements.GetByName("joeClass1");
                    Object obj3 = collectionElements.GetByName("joeClass2");

                    EA.Element element2 = (EA.Element)obj2;
                    EA.Element element3 = (EA.Element)obj3;

                    EA.Collection collectionDiagramObjects = diagram1.DiagramObjects;
                    Object obj4 = collectionDiagramObjects.AddNew("", "");
                    EA.DiagramObject dobj2 = (EA.DiagramObject)obj4;
                    dobj2.bottom = 2 * dobj2.bottom;
                    dobj2.right = 2 * dobj2.right;
                    dobj2.ElementID = element2.ElementID;
                    if(!dobj2.Update())
                    {
                        MessageBox.Show("Error");
                        return;
                    }
                    collectionDiagramObjects.Refresh();


                    Object obj5 = collectionDiagramObjects.AddNew("", "");
                    EA.DiagramObject dobj3 = (EA.DiagramObject)obj5;
                    dobj3.ElementID = element3.ElementID;

                    if (!dobj3.Update())
                    {
                        MessageBox.Show("Error");
                        return;
                    }
                    collectionDiagramObjects.Refresh();

                    Repository.OpenDiagram(diagram1.DiagramID);


9
Hi
I created (in C# using Automation Interface) a diagram and added an element on this diagram. Now I want to change the position and the size of this element in the diagram view. I try unsucessfully to do it with the Attribute Bottom, Top, Right and Left of the class DiagramObjets.
Somebody can help me please!
Regards

Pages: [1]