I've been searching the forums trying to come up with a way to adjust the column width to not word wrap and use a single line of text. Ive mod'ed this routie to scale text to the drawing scale. I get stuck on the column width wants a numeric value...
(defun c:LISTBLK (/ ss name block blocks insPt table row)
(vl-load-com)
(or *acdoc*
(setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object)))
)
(or *blocks*
(setq *blocks* (vla-get-Blocks *acdoc*))
)
;; Select blocks
(prompt "\nSelect blocks to list or <All>")
(or (setq ss (ssget '((0 . "INSERT"))))
(setq ss (ssget "_X" '((0 . "INSERT")))
)
)
(if ss
(progn
;; Build a list of dotted pairs (blockName . numberOfReferences) from the selection set
(vlax-for x (setq ss (vla-get-ActiveSelectionSet *acdoc*))
(if (not (vlax-property-available-p x 'Path))
(setq name (vla-get-EffectiveName x)
blocks (if (setq block (assoc name blocks))
(subst (cons name (1+ (cdr block))) block blocks)
(cons (cons name 1) blocks)
)
)
)
)
(vla-delete ss)
;; Prompt for inserrtion point
(initget 1)
(setq insPt (trans (getpoint "\nInsertion point: ") 1 0))
;; Create the table
(setq table (vla-addtable
(vla-get-modelspace *acdoc*)
(vlax-3d-point insPt)
(+ 2 (length blocks)) ; number of rows (including title and header)
3 ; number of colums
0.432632 ; cell height
1.730527 ; row width
)
)
(vla-put-HorzCellMargin table 0.060000)
(vla-put-VertCellMargin table 0.060000)
(vla-put-TitleSuppressed table :vlax-false)
(vla-put-HeaderSuppressed table :vlax-false)
(vla-SetTextHeight table acTitleRow (setq DS (getvar "dimscale")G:TS (* 0.1875 DS)))
(vla-SetTextHeight table (+ acDataRow acHeaderRow) (*(getvar "dimscale")(getvar "dimtxt")))
;; Fill the titel and the header
(vla-setText table 0 0 "Bill of Materials")
(vla-setcolumnwidth table 0 2) ; 0 is first column
(vla-setText table 1 1 "QTY.")
(vla-setcolumnwidth table 1 2)
(vla-setText table 1 2 "Description")
(vla-setcolumnwidth table 2 25)
(vla-setText table 1 0 "Item")
;; fill the following rows from the list contents
(setq row 2)
(foreach item blocks
(vla-settext table row 1 (cdr item)) ; references count
(vla-settext table row 2 (car item)) ; block name
(setq row (1+ row))
)
)
)
(princ)
)