Search code examples
autolisp

Is there any way to access the information on a atribute text inside a block object ? (Autolisp)


Basically, I want a function that goes through the drawing and searchs for attribute definition text, I can do it normally, but if I make a block with said attribute text the function can't find them anymore. I don't know if it's even possible to do it.


Solution

  • To achieve your task, you'll want to look at the value (Textstring property) of the attribute references, as opposed to the attribute definitions.

    Attribute references are held by the block reference and their values may vary between multiple references of the same block, whereas attribute definitions reside within the single block definition (i.e. the blueprint for the block) and hold an optional default value.

    The attribute references may be accessed either through Vanilla AutoLISP using the entnext function to iterate over the attribute reference subentities which follow a block reference entity in the drawing database (example), or through Visual LISP by invoking the ActiveX getattributes method (example).

    My existing Count Attribute Values program should provide some insight into how to accomplish this - you'll only need to differentiate the references by block name in addition to attribute value.