try this modification of the script:
http://gtr.quakedev.com/weapon_wrench.script
aligns on walls and its possible to add portals far away.
sadly, portals dont work too close to walls, so a boxtrace was neccessary.
trace doesnt go through portals.
edit: point trace and exact distance to wall added.