OK. I reformatted your code so I could read it - it is completely scrambled above.
Anyway, this code isn't inside a procedure, but I think the point is that you've written it as a set of function calls as you'd get in a replay file. When you execute some of these functions, they block until some interactive operation has occurred - and hence the subsequent statements in code won't work. It works if replayed as a replay file (e.g. using hiReplayFile() ), but that's not a very elegant solution.
In this particular case, you'll probably be best using my Sourcelink Solution 11323850, which provides a function to draw an MPP using a named template. This can easily be used in procedural code.
In reply to Andrew Beckett:
Thank you Mr. Andrew... It is working well.. Hats off to your ideas...
Prabhakar.K -- Layout Engineer