Changing Family Parameter Parameter Group

I have a few families that I need to be able to change the Parameter Group of Family Parameters.

Here is the code I currently have:

pgGroup = BuiltInParameterGroup.PG_GRAPHICS

doc = uiapp.OpenAndActivateDocument(i).Document
	
paramList = [i for i in doc.FamilyManager.Parameters]
		
t = Transaction(doc, "test")
t.Start()
	
for i in paramList:
	if i.Definition.Name in ["Right Sidesplash Edge line", "Left Sidesplash Edge line"]:
		i.Definition.ParameterGroup = pgGroup
		
t.Commit()
	
doc.Save()

This does change the parameter group as desired, but when I close the family and reopen it, the parameter group returns to it’s previous state.

Does anyone have any idea what is going on?

Thanks!

I don’t know how you run that code at the moment but you could need to adapt it for using in Dynamo, see: