The first thing I noticed:
(setq OldBLkNM (vla-get-Name VL-Blk))
change to:
(setq OldBLkNM (vla-get-EffectiveName VL-Blk))
EDIT: Btw whats that _value function? I'm a bad reader, sorry.
Instead of:
(SETQ NewBlkNm (VLA-GET-TEXTSTRING (_value "\nSelect New name for Block: ")))
(setq NewLy (strcat "L-PLNT-TREE-" (VLA-GET-TEXTSTRING (_value "\nSelect Code: "))))
I would suggest:
(setq NewBlkNm (getV "\nSelect New name for Block: "))
(setq NewLy (strcat "L-PLNT-TREE" (getV "\nSelect Code: ")))
with:
(defun getV ( msg / e txt )
(setvar 'errno 0)
(while (/= 52 (getvar 'errno))
(setq e (car (nentsel msg)))
(cond
((= 7 (getvar 'errno)) (princ "\nMissed.") (setvar 'errno 0))
((/= (member (cdr (assoc 0 (entget e))) '("TEXT" "MTEXT" "ATTRIB")))
(princ "\nInvalid object.")
)
((and e (not (snvalid (setq txt (cdr (assoc 1 (entget e)))))))
(princ "\nInvalid content.") (setq txt nil)
)
(txt (setvar 'errno 52))
(T nil)
); cond
); while
(if txt txt "")
); defun
EDIT2:
Also change this part:
(if (equal OldBLkNM NewBlkNm)
(vlax-put-property VL-Blk 'layer NewLy)
(progn
(vlax-put-property VL-Blk 'layer NewLy)
(vlax-put-property VL-Blk 'name NewBlkNm)
)
)
To:
(if (equal OldBLkNM NewBlkNm)
(vlax-put-property VL-Blk 'layer NewLy)
(progn
(vlax-put-property VL-Blk 'layer NewLy)
(vlax-put-property
(vla-item
(vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
(vla-get-EffectiveName VL-Blk)
)
'Name
NewBlkNm
)
)
)