Group atoms that are bonded

I have a polymer consistent of monomers of atome type 1 and some free atoms of type 2 that can bound to the monomers. I now want to group all the atoms of type 2 that bonded to those of type 1 so that I can change them at a certain rate to type 3.

I have trouble finding a way to fillter only the bonded ones.

Help would be greatly appreciated.

Have you looked at compute fragment/atom?