Problem using import from excel example

I am trying to use the example script ‘Import_physical_components_from_xlsx’. I am using it exactly as provided, the script correctly makes a physical component for each cell in the excel but they all have the default name (PC number) and do not use the name from the cell as defined in the line:


I added a debug line of code to check that the name was being written:


Which showed that the variable pc has been given the name, but it is not being used when the element in the model is created. So I wondered if it is an issue with this line


I also added pc.set_summary(cell.value), which correctly put the cell value as the physical component summary.

As it is using the sample script out of the box I thought my setup was wrong, but cannot see anything. Does anyone have any advice on what could be the issue or what I could do to further debug this?

Thanking anyone who can help me with this.

@YvanLussaud there is a bug in this script.
The line org.polarsys.capella.core.model.helpers.CapellaElementExt.creationService(pc.get_java_object()) was added to this script and for some reasons it remove the names of the PC.
I would be interested to know the role of this line.

@Alexh move the pc.set_name(cell.value) line after the line org.polarsys.capella.core.model.helpers.CapellaElementExt.creationService(pc.get_java_object()) and you’re good to go.



This line is used to configure the passed object from a Capella point of view. For PhysicalComponent it will add and set the corresponding Part for instance. I don’t know why it has a side effect on the component name but I’ll fix the script. Thank you.

PS: the creationService() also set a default name…

1 Like

@YvanLussaud & @StephaneLacrampe Thank you both for your brilliant replies. I now have the example script and my specific application working.

1 Like