Programmatically Creating Blocks

Check out this thread.