include functional group in the model

Hi, there

Does anyone know that is there any script that could include functional group in the existed models. I know MS provides the function to select the desired functional group, then click to connect it to your structure. However my model has ~30,000 atoms, i don't think it is wise to include them one by one manually.

Thanks~!