I've modified my last code I hope finally... It should work without any bugs, so if you check it and find some errors, please report me...

Sincerely, M.R.

Just checked it, and it bugs when executing from main plan view, so to get it function well turn your view to any 3D view...
M.R.