- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone, I would like to populate an AutoCAD block with attributes with values pulled from an AutoCAD table. I've tried a few different LISP routines and can't figure out how to pair them up.
This post from @Anonymous is very close to what I'm after, but I don't want to pull the data from an Excel file:
Find & replace 'Attribute TEXT value' based on input provided in XLS
I've found a LISP that extracts the values from each cell of the table and assigns them to a separate variable, but I don't know how to push those values into my block attributes.
Here is the code for the lisp that extracts the table cell values. Could I get some help adding on to it please? Any help is appreciated.
(defun c:TDE (/ c ctr dat etdata ind lst prefix r tab tblent tblobj val varname)
(setq etdata (entget (setq tblent (car (entsel "\nSelect table object: "))))
ind (cdr (assoc 91 etdata))
tab (cdr (assoc 92 etdata))
r 0 ;;;This determines which row to start with
c 0 ;;;This determines which column to start with
ctr 1 ;;;This is the starting variable # (var1, var2, etc.)
prefix "var"
tblobj (vlax-ename->vla-object tblent))
(while (< c tab)
(while (< r ind)
(set (setq varname (read (strcat prefix (itoa ctr))))
(setq val (vlax-invoke tblobj 'getcellvalue r c)))
(setq lst (cons (setq dat (cons varname val)) lst))
(setq ctr (if (listp (cdr dat))
ctr
(1+ ctr))
r (1+ r)))
(setq r 0
c (1+ c)))
(vl-remove-if '(lambda (x) (listp (cdr x))) (reverse lst)))
Solved! Go to Solution.