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?

These are what my elements look like.
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.