Here is a start, like StevenP Google is your friend. make-example-table.lsp
A double check is to select text then double check find the nearest pline vertice point and use that, if your text is not exactly on a point you will get a incorrect answer.
There was no error but the goal of the program was targeting attributed blocks and not dynamic blocks with parameters and that was my misunderstanding with your request.
Anyway, please try the following :
(defun c:Test (/ int sel ent blk val prp prs rtn lst)
;; Tharwat - Date: 27.Mar.2022 ;;
(and (princ "\nSelect Dynamic blocks to replace D1 & D2 with OHd value : ")
(setq lst '("OHd" "D1" "D2")
int -1
sel (ssget '((0 . "INSERT"))))
(while (setq int (1+ int) ent (ssname sel int))
(and (= (vla-get-IsDynamicBlock (setq blk (vlax-ename->vla-object ent))) :vlax-true)
(setq prs (vlax-invoke blk 'getdynamicBlockproperties))
(mapcar '(lambda (u)
(and (vl-position (setq prp (vla-get-propertyname u)) lst)
(or (and (= prp (car lst)) (setq val (vlax-get u 'Value)))
(setq rtn (cons u rtn))
)
)
)
prs)
val rtn
(mapcar '(lambda (u) (vlax-put u 'Value val)) rtn)
(setq rtn nil)
)
)
)
(princ)
) (vl-load-com)
OSOPTIONS, set to ignore Hatch Objects, easiest to do through Options-Drafting-Object Snap Options and select "Ignore hatch objects".
As mentioned, mostly sounds like a computer issue. What OS are you using?
Can you post a drawing with this problem, just to check?