Author Topic: SysML: Making a recursive dump of a full BDD structure  (Read 8663 times)

maaroe

  • EA Novice
  • *
  • Posts: 5
  • Karma: +1/-0
    • View Profile
SysML: Making a recursive dump of a full BDD structure
« on: April 05, 2024, 07:38:22 am »
Hi,

I'm fairly new to EA scripting and particularly the API/datamodel although I've done my fair share of software development.

My goal is to create a script Project Browser script, that takes the selected SysML::Block object in the project browser and recursively extracts the Parts in the structure into a CSV file.

Example:
A BDD is created establishing the below hierarchical structure using "Composition to Whole" links between SysML::Block elements on the diagram.

Block A (selected)
  - Part x
  - Part y
  - Part z
    - Part z1
    - Part z2

Question 1:
How do I extract this information into a CSV file with the structure described below?
--------------------------
Level   Name   Parent
0         A
1         x         A
1         y         A
1         z         A
2         z1       z
2         z2       z

I've tried starting from Block A and iterating through all of the "Part" Elements in the EmbeddedElements Collection and extracting the Part.PropertyTypeName for each Part in the collection. This works well for level 1. Then the idea was to iterate through each Element in the Part.EmbeddedElements and so on until reaching the Parts with empty EmbeddedElements Collections. However, all the Parts in Level 1 have empty EmbeddedElements Collections even though they are defined identically in the BDD diagram, so the script stops at level 1.

Question 2:
I would want to add metadata to the Blocks/Parts and have that exported in relevant columns as well. For now the list of columns is predefined, so there is no dynamic creation of new columns or similar.
But I run into the same type of problem here. The top-level Block has an Attribute (e.g. "PartNo" = "testPartNo") which is found by the script and exported in the array structure that will eventually be saved to a CSV file. But all of the members of the EmbeddedElements Collection (which have Type = "Part" rather than "Block"... because they are instances(?)) have empty Attributes Collections, even though the Block definitions from which the instances where created have Attributes defined.

In the end, I want to use something similar to walk through the BDD tree and aggregate Mass value properties to get total weight etc, so I will also need to get Multiplicity involved (another parameter that eludes extraction from Parts), but for now I would be happy with the above.

So maybe it is actually a single question:
When a Block becomes a Part due to the composition to whole relationship, where do the Collections of EmbeddedElements and Attributes go?
I can see, that the Name goes into PropertyTypeName, but where does the rest go?

It seems like a fairly obvious thing to want to export for use in other tools (like a PLM system) or for reporting...

Thanks in advance (I've been trying to find a solution to this for the entire day but no progress).

// Morten

PS:
I have some simple screendumps of the BDD and project browser, but how do I include them in the post?