As Eric mentioned, this is pretty quick if you turn on macro recording and do it. I made one months back for my perspective viewport:
actionMan.executeAction 0 "40182"
actionMan.executeAction 0 "311"
No matter where I'm at, it will change to perspective and zoom extents on the currently selected mesh.