You can use Power shell and SMO to script out objects and its dependents in a database along with object permissions. This blogs entry has a sample power shell script that you can use to generate script in automated way.
The end result includes table generation script twice for the tables used by views. WithDependencies option does not only calculate dependencies and reorder them, but also add any tables needed. So the resulting script is not runnable. Is there a way to solve this problem?