You can mark groups of atoms as belonging to a rigid body. They will be moved together during optimization, such that their relative orientations do not change. These are created by making a rigid_body object and adding it to the restraints.rigid_bodies list.
rigid_body(*atom_ids)
Creates a new rigid body which contains all of the specified atoms.
from modeller import *
env = environ()
env.io.atom_files_directory = '../commands'
mdl = model(env, file='1fas')
# Keep residues 1-10 rigid:
r = rigid_body(mdl.residue_range('1:', '10:'))
mdl.restraints.rigid_bodies.append(r)
# Randomize the coordinates of the whole model; the rigid body remains rigid
sel = selection(mdl)
sel.randomize_xyz(deviation=4.0)
mdl.write(file='1fas.ini')