Book a Demo

Author Topic: Problems in displaying ports in Diagram using C#  (Read 2688 times)

hshahid

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Problems in displaying ports in Diagram using C#
« on: October 08, 2010, 01:24:36 am »
Hi All,

I using C# and EA API to create a SysML model. I created a block and added a port in with that block, I am able to see the port added with the block but I am having problems in displaying a "Port" with the block  in the diagram. Please advise.

           element = (EA.Element)package.Elements.AddNew("TestBlock", "Class");
           element.MetaType = "Block";
           element.Stereotype = "Block";
           {
               attribute = (EA.Attribute)element.Attributes.AddNew("Length", "int");
               attribute.Update();
               attribute = (EA.Attribute)element.Attributes.AddNew("Width", "int");
               attribute.Update();
               attribute = (EA.Attribute)element.Attributes.AddNew("Height", "int");
               attribute.Update();

               embdElement = (EA.Element)element.EmbeddedElements.AddNew("TestPort", "Port");
               embdElement.MetaType = "FlowPort";
               embdElement.Update();
               }
element.Update();

           left = 100;
           right = 200;
           top = 100;
           bottom = 200;
           position = "l=" + left + ";r=" + right + ";t=" + top + ";b=" + bottom + ";";
           dObj = (EA.DiagramObject)diagram.DiagramObjects.AddNew(position, "");
           dObj.ElementID = element.ElementID;
           dObj.Update();
       }
       diagram.Update();

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Problems in displaying ports in Diagram using
« Reply #1 on: October 08, 2010, 09:09:10 am »
You will also need to create a DiagramObject for the port.
The Sparx Team
[email protected]