PDA

View Full Version : How to name objects



paul.hives
2008-12-15, 03:30 PM
Is there a way to name objects or refer to them by Block Name and Attribute Name.

Building formulas with fields like this is way to cumbersome:

%<\AcExpr (%<\_FldPtr 2125560568>%+%<\_FldPtr 2125560576>%+%<\_FldPtr 2125560584>%+%<\_FldPtr 2125560592>%+%<\_FldPtr 2125560600>%+%<\_FldPtr 2125560608>%+%<\_FldPtr 2125560616>%+%<\_FldPtr 2125560624>%+%<\_FldPtr 2125560632>%+%<\_FldPtr 2125560640>%+%<\_FldPtr 2125560648>%+%<\_FldPtr 2125560656>%+%<\_FldPtr 2125560664>%+%<\_FldPtr 2125560672>%+%<\_FldPtr 2125560680>%+%<\_FldPtr 2125560688>%+%<\_FldPtr 2125560696>%+%<\_FldPtr 2125560704>%+%<\_FldPtr 2125560712>%+%<\_FldPtr 2125560720>%+%<\_FldPtr 2125560728>%+%<\_FldPtr 2125560736>%)>%

I need something like dot notation like: Block.Attr.Value

irneb
2010-01-24, 10:39 AM
That field code is a formula with nested fields. You could generate a formula like this:
%<\AcExpr (%<\AcObjProp Object(%<\_ObjId 2130532480>%).TextString>%+%<\AcObjProp Object(%<\_ObjId 2130532480>%).TextString>%)>%Where the number following the ObjId is the COM ObjectId property of the attribute. You can obtain this using lisp:
(setq en (nentsel "Pick attribute:")) ;Select the attribute
(setq eo (vlax-ename->vla-object (car en))) ;Get the COM Object
(princ "The object's Id is: ")
(princ (vla-get-ObjectId eo))
(princ)