I posted the source code for my SQL Server 2005 object scripting tool. The code reads like something I threw together to see if I could really do this. Because that's what it is. You can read a prior post that describes a little of what it does.
This is a companion discussion topic for the original entry at http://billg.sqlteam.com/2005/12/24/8613/