@Ashishs
Give this version a try:
;; Written by PJK 11/26/2024
;; Topic: https://www.cadtutor.net/forum/topic/94150-looking-for-a-lsp-to-select-a-dimension-in-the-drawing-and-change-the-color-to-red-for-any-type-of-dimension-be-it-a-rotated-aligned-or-angular/
(defun c:dimred (/ e e2 i l l2 ss)
(if (setq ss (ssget '((0 . "DIMENSION,*LEADER"))))
(repeat (setq i (sslength ss))
(setq e (ssname ss (setq i (1- i)))
l (entget e)
)
(if (wcmatch (cdr (assoc 0 l)) "DIMENSION,LEADER,QLEADER")
(progn
(command "._dimoverride" "_dimclre" 1 "_dimclrd" 1 "_dimclrt" 1 "" e "")
(if (assoc 340 l)
(progn
(setq l2 (entget (setq e2 (cdr (assoc 340 l)))))
(if (assoc 62 l2)
(progn (entmod (subst (cons 62 1) (assoc 62 l2) l2))(entupd e2))
(progn (entmod (append l2 (list (cons 62 1))))(entupd e2))
)
)
)
)
(if (assoc 62 l)
(progn (entmod (subst (cons 62 1) (assoc 62 l) l))(entupd e))
(progn (entmod (append l (list (cons 62 1))))(entupd e))
)
)
)
)
(princ)
)