I don't think you need a script. Increase your constraint from trace to pad. Although I am not a Pads user, every Cad tool I have used has the ability to define obstructs to deal with the problem you face. You may find better responses in the Pads community.
Good luck.