Is it possible to create a block with field in attribute which can be attached to different objects?

I'am trying to create a block which may be used for area reporting. I'am able to define some attribute there containing a field attached to some polyline. But when I insert second instance of block, that field is still attached to the first polyline. Is possible to reattach the field from the second block to another polyline? Or it can't be done it this way?

Comments

  • A field contains a object ID so the way around is to insert the block but add the attribute text as a field with the correct object id. Change length with area. You may need to change the Lu6 as well as I am metric.

    ; Pick a line and put its length in a attribute
    ; By Alan H Feb 2021 info@alanh.com.au

    (defun llen ( / obj objid str )
    (setq obj (vlax-ename->vla-object (car (entsel "Pick obj"))))
    (setq objid (rtos (vla-get-Objectid obj) 2 0))
    (setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId " objid ">%).length \\f \"%lu6\">%"))
    (setq obj (vlax-ename->vla-object (car (nentsel "Pick attribute"))))
    (vla-put-textstring obj str)
    (command "regen")
    (princ)
    )
  • Great, that works. Thank you!