Good. I guess not re-creating the segment editor widget fixed the selection reset issue.
Brush parameters are shared between paint and erase effects, so it is a common parameter, which need to be set by using setCommonParameter
method:
effect.setCommonParameter("BrushDiameterIsRelative", "0")
effect.setCommonParameter("BrushAbsoluteDiameter", newDiam)