Hi all,
Recently I started a project that involves placing SysML blocks and parts in EA via a COM connection.
I’ve previously made a little plugin for EA using C# and the API, but for this project, I use Python and simply connect via COM to EA. This works exactly the same.
However, I’ve gotten stuck on an issue. In this case, I want to create three Blocks, let’s name them B1, B2, and B3. My objective is to add a Composition relation between B1 and B2, and B1 and B3 (with B1 parent in both cases). To complete this composition, I would also like two part properties to be created that are child elements of B1, one with the type B2, the other with the type B3. This is similar to what would happen if you use the “Synchronize Structural Elements” button that is available for SysML Internal Block Diagrams (which are also called CompositeStructure in EA).
Creating the three Block elements was not that difficult, as I had done this before. I was also able to connect B1 with B2 and B1 with B3 using a connector of composite type, see the Python code below:
connector = part.Connectors.AddNew("", "Composition")
connector.SupplierID = type.ElementID
connector.SupplierEnd.Aggregation = 2
connector.Update()
It took some time to figure out you needed this Aggregation 2. Using this, the Relationship also became visible in EA as a composite relationship.
However, EA did not automatically show the part properties of B1 that you would get if you made this connection via the EA client. These part properties would only show up when you used the “Synchronize Structural Elements” button after creating an IBD. Thus, I set on to creating these Part Properties manually, using the following code:
part_in_type = type.Elements.AddNew("", 'Part')
part_in_type.PropertyType = part.ElementID
part_in_type.Update()
type.Elements.Refresh()
Here, I create an Element of type “Part”, which I connect to the part using its ElementID. These showed up nicely, however, this is where the problem showed up.
At this point, already with two part properties for B1, when you click “Synchronize Structural Elements”, EA created two additional part properties, which look identical. The only difference is that the part properties I created (for some reason) are shown as “Properties” in a Block Definition Diagram, while the ones EA creates are properly shown as “Parts”. I tried moving them around by, for example, enabling isReference (which makes it a reference instead of a part), and this indeed moved the EA created "Parts" to "References". It also moved my created parts from "Properties" to "References", but I couldn't get them to move to "Parts".
I’ve checked the parts that I’ve created and EA creates out using my C# plugin, and they are completely identical as far as I can see. Does anyone know what I am doing wrong or how I can emulate the “Synchronize Structural Elements” button for Internal Block Diagrams? Thanks very much in advance!