Then try IDP.lsp function that does this for you automatically.
Code:
; idp.lsp if in pspace, will toggle to mspace to get id point then return to pspace
(defun c:idp (/ cvport cmdecho menuecho)
(setq cmdecho(getvar"cmdecho")) ; save current command echo setting
(setq menuecho(getvar"menuecho")) ; save current menu echo setting
(setvar"menuecho"1) ; make sure menu echo is on
(if(= 1 (setq cvport(getvar"cvport")))(command"_.Mspace")) ; chk if in pspace, then toggle to mspace
(command"_.ID") ; start ID command
(while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause)) ; pause until ID command is complete
(setvar"cmdecho"0) ; turn command echo off
(if(= 1 cvport)(command"_.Pspace"))(princ) ; if was in pspace willn toggle back
(setvar"cmdecho"cmdecho) ; set command echo back
(setvar"menuecho"menuecho)(princ) ; set menu echo back
)(princ)
(princ"\nIDP command loaded.")(princ)