I wonder if the basic recipe would be bandsome instead (and/or before the idealize one).

Band to atom or rotamers commands could be used.

The available commands are:

band.Add(integer segmentOrigin, integer segmentXAxis, integer segmentYAxis, number rho, number theta, number phi, [integer atomIndexOrigin], [integer atomIndexXAxis], [integer atomIndexYAxis])

band.AddBetweenSegments (integer segmentIndex1, integer segmentIndex2, [integer atomIndex1], [integer atomIndex2])

band.AddToBandEndpoint (integer segmentIndex, integer bandIndex, [integer atomIndex])

The problem is combining these commands because there is no command to "turn" an atom using the first command.

Then, for rotamers, I don't know if the following commands actually work:

structure.TweakRotateinteger (segmentIndex, number angle)

structure.TweakShift (integer segmentIndex, boolean shiftDirection)

and this ones, but how to identify the right angles ?

rotamer.GetCount (integer segmentIndex)

rotamer.SetRotamer (integer segmentIndex, integer position)

Not sure there is a solution with current commands, but that's a nice scripting chalenge.