Changing parameters of elements inside model groups

I am aware that this topic has been discussed before (approx 5 years ago) but I couldn’t find a clear solution for the problem.

I’ve made the following script, which takes all the Curtain Walls inside the filtered Model Groups and changes its parameters called “Comments” to the same name as the Model Group’s name.

Now the problem is; the moment I run the script, Revit is forcing me to Ungroup the Model Groups in order to be able to change the parameters of the Curtain Walls in those Model Groups. It’s doing this with the following error:
image

Now the only solution I am able to find and think of is by ungrouping and regrouping the Model Groups with the same name after changing the parameters of the Curtain Walls. And also deleting the previous Model Groups so there won’t be any duplicate names of different Model Groups inside the project.

Could anyone help me out?

Why Comments?

Just make a Group-independant (Shared) Project parameter for this kind of stuff, works perfectly.

The windows are made up with Curtain Walls in the projects (don’t ask me why, standardized in the company’s library). The instances vary by their dimensions and some of them have the same dimensioning, thus making these the same type. The types are also defined by the model group names, the question came to me if it is possible to provide the same name as the model group to the curtain walls (window types) inside of those model groups, which is done manually atm. And why they use the “comments” parameter for it, is probably because they agreed it would be to some other party? (possibly manufacturer?)