Ok, I found this lisp and I was wondering if anyone can help me change this to work with an attibuted block.
Basically, this routine will ask the user to select a lwpolyline, then ask the user to select a point for the label, it will then create a text abject and change it to reflect the lwpolylines square footage with the use of reactors so that if the shape of the lwpolyline changes then the text auto-updates itself.
I would like this to do the same but with a attributed block. Any idears....
See code below:
(vl-load-com)
(Setq acadApp (vlax-get-acad-object)
acadDoc (vla-get-ActiveDocument acadApp)
mSpace (vla-get-ModelSpace acadDoc)
)
(defun esq_xdlist (ename rname / data elist)
(setq elist (entget ename (list rname)))
(setq data (cdr (car (cddr (cadr (assoc -3 elist))))))
)
(defun esq_xdata (ename rname l_code l_valeur / xd_list elist xd_type input)
(setq elist (entget ename))
(regapp rname)
(setq xd_list (list '(1002 . "}")))
(repeat (length l_code)
(setq xd_type (car l_code)
l_code (cdr l_code)
input (car l_valeur)
l_valeur (cdr l_valeur)
xd_list (cons (cons xd_type input) xd_list)
)
)
(setq xd_list (cons '(1002 . "{") xd_list))
(setq xd_list (cons rname xd_list))
(setq xd_list (list -3 xd_list))
(setq elist (cons xd_list elist))
(entmod elist)
(prin1)
)
(defun c:mksurf()
(if (setq curEnt (car (entsel)))
(setq curObj (vlax-ename->vla-object curEnt)
curArea (vla-get-area curObj)
)
)
(setq curpoint (getpoint"\npick label insertion point : "))
(setq curArea (rtos curArea 2 2))
(setq ObjText (vla-addtext mspace curArea (vlax-3d-point curpoint) 0.25))
(setq entext (entlast))
(esq_xdata curEnt "ESQ2001-1" (list '1005) (list (cdr (assoc 5 (entget entext)))))
(setq SurfReactor (vlr-object-reactor (list CurObj) "Surface Reactor" '((:vlr-modified . modif-texte))))
(vlr-pers SurfReactor)
)
(defun modif-texte (notifier-object reactor-object parameter-list)
(cond
(
(vlax-property-available-p
notifier-object
"Area"
)
(setq newarea (strcat (rtos (/ (vla-get-area notifier-object) 144) 2 2)" Sq. Ft."))
(setq handle (esq_xdlist (vlax-vla-object->ename notifier-object) "ESQ2001-1"))
(vlax-put-property (vlax-ename->vla-object (handent handle)) "TextString" newarea)
)
)
)
I use Autocad 2002 for now.