Message 1 of 20
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've been searching for this lisp for awhile and just found it on another thread. Can someone help me to modify it?
Lisp works well as it is, the only changes i a want to make are:
- An option to WINDOW or select ALL
- Insert a table location. Something like this: (defun insert_table (lst pct / tab row col ht i n space)
- If 2 is too complicated i'd be happy with 1 option
;| http://www.cadtutor.net/forum/showthread.php?83991-Populate-Table Original by Oleg Fateev Modified by hms 2014/11/14 as a 'demo' to JCprog http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/extract-attributes-from-a-specific-block-and-write-to-table/m-p/5399759#U5399759 |; (defun C:CLIST (/ a1 a2 a3 acapp acsp adoc atable attdata atts col headers pt row title) (or adoc (setq adoc (vla-get-activedocument (setq acapp (vlax-get-acad-object)))) ) (or acsp (setq acsp (vla-get-block (vla-get-activelayout adoc))) ) (vlax-for blk (vla-get-blocks adoc) (if (= (vla-get-IsXref blk) :vlax-true) (vlax-for x blk (if (and (= (vla-get-ObjectName x) "AcDbBlockReference") (wcmatch (vla-get-EffectiveName x) "*|blk01") ) (progn (setq atts (vlax-invoke x 'getattributes)) (foreach att atts (cond ((wcmatch (vla-get-tagstring att) "tag01") (setq a1 (vla-get-textstring att)) ) ((wcmatch (vla-get-tagstring att) "tag02") (setq a2 (vla-get-textstring att)) ) ((wcmatch (vla-get-tagstring att) "tag03") (setq a3 (vla-get-textstring att)) ) ) ) (setq attdata (cons (list a1 a2 a3) attdata)) ) ) ) ) ) (if (setq pt (getpoint "\nSpecify table location:")) (progn (setq atable (vla-addtable acsp (vlax-3d-point pt) (+ 2 (length attdata)) 3 (/ (getvar 'dimtxt) 2) (* (getvar 'dimtxt) 4) ) ) (vla-put-regeneratetablesuppressed atable :vlax-true) (setq col 0) (foreach wid (list 10.0 10.0) (vla-setcolumnwidth atable col wid) (setq col (1+ col)) ) (vla-put-horzcellmargin atable 0.3) (vla-put-vertcellmargin atable 0.3) (vla-setTextheight atable 1 2.0) (vla-setTextheight atable 2 1.4) (vla-setTextheight atable 4 1.4) (setq title "Demo") (vla-setText atable 0 0 title) (vla-setcelltextheight atable 0 0 2.0) (vla-SetCellAlignment atable 0 0 acMiddleCenter) (setq headers (list "Tag01" "Tag02" "Tag03")) (setq row 1 col 0 ) (repeat (length headers) (vla-SetCellAlignment atable row col acMiddleCenter) (vla-setcelltextheight atable row col 1.4) (vla-setText atable row col (car headers)) (setq headers (cdr headers)) (setq col (1+ col)) ) (setq row 2) (foreach record attdata (setq col 0) (foreach item record (vla-setText atable row col item) (vla-SetCellAlignment atable row col acMiddleCenter) (vla-setcelltextheight atable row col 1.4) (setq col (1+ col)) ) (setq row (1+ row)) ) (vla-put-regeneratetablesuppressed atable :vlax-false) (vla-put-height atable (+ (* (vla-get-rows atable) 2.2) 4.1)) (vla-update atable) ) ) (princ) ) (prompt "\n\t---\tStart command with CLIST\t---\n") (prin1) (or (vl-load-com)) (princ)
Thanks
Solved! Go to Solution.