Down in the code that @ВeekeeCZ linked there is this:
(setq s
(strcat "%<\\AcObjProp Object(%<\\_ObjId "
(LM:GetObjectID doc (vlax-ename->vla-object p)) ">%).Length \\f \"%lu6\">%"
)
)
which constructs the field string for Length of the object whose symbol in the code is 'p. Put that string as your attribute value and it is done!
What you are asking for is in there. It seems that the code to define 'doc which is one of the two inputs required by (LM:GetObjectID doc obj) is not included. However, 'doc is a pretty standard construct during the setup of most (VLAX-...) function calls but I am still a noob in my understanding of it so I'll leave it to another to provide that for you.
(defun LM:GetObjectID ( doc obj )
(if (eq "X64" (strcase (getenv "PROCESSOR_ARCHITECTURE")))
(vlax-invoke-method (vla-get-Utility doc) 'GetObjectIdString obj :vlax-false)
(itoa (vla-get-Objectid obj))
)
)
I am elated to find code that gets the Object ID! I've been wanting this for a while now. Thanks Lee Mac
AutoCAD User since 1989. Civil Engineering Professional since 1983
Product Version: 13.6.1963.0 Civil 3D 2024.4.1 Update Built on: U.202.0.0 AutoCAD 2024.1.6
27.0.37.14 Autodesk AutoCAD Map 3D 2024.0.1
8.6.52.0 AutoCAD Architecture 2024