Python Script to export components table

Hi All,

I am not sure if I am allowed to ask for this, but could you please provide me with a python script to export such a table from my physical architecture diagram, using python4capella, as shown in the screenshot?

Screenshot from 2024-08-26 10-25-43

You can find some sample scripts here that will help you getting started. This script list physical components to an Excel file and this one is probably even closer to what you want to export.

One difference is the starting point of your script, instead of listing all elements form the Capella model, you need to select only those from a diagram. The following script list all diagrams and their shown PhysicalComponent:

for diag in model.get_all_diagrams():
    for comp in diag.get_represented_elements():
        if isinstance(comp, PhysicalComponent):
            print(comp.get_name())
1 Like

Hi @YvanLussaud ,

Many thanks :smiley: :smiley: I much appreciate it, even the script listing all diagrams sounds so useful, I didn’t have the idea of doing it before, but now I find it great !

1 Like