If your using AutoCAD their is a simpler way to pull values. but it doesn't work with my version of BricsCAD. Give this a try and see if it works.
https://help.autodesk.com/view/OARX/2022/ENU/?guid=GUID-8E5913FC-09ED-4C70-AFB7-2431C062E899
See if this new code works.