Generic model as wall opening

Hi everybody,

First excuse my english, i will try my best to be understandable.

I am working on a script wich wil creat a generic model at the intersection between wall and pipe/duct.
I read a lot of things on this forum and the creation and postionning is ok.

Then i want that the generic model have the size of the duct/pipe+X cm.

It is at this point that i have an issue.
There is a generic model for each intersection but the size is wrong.

If in my project there are 3 ducts lenght 30-50-45 there are also 3 generic model 30+X-50+X-45+X but the generic model are not placed on the good duct.

I think it is a sorting problem but i didn’t find solution.

It is not easy to explain with my level of english.

You can find the script here
And the project file here

The generic model family is in the project “famille 1”

Thanks a lot

Nicolas

The script

Nicolas

And my issue

There are 4 duct 30-50-40-60
And 4 generic model 40-70-60-50
The dimensions are ok, i want largeur+10, but not at the correct location …

Thanks