Try this .
Code:
(defun c:Test (/ WriteAndSet columns e ss l hgt inc ins rows p r tbl)
;; Tharwat 23. May. 2014 ;;
(if l
(progn
(setq hgt
(if
(zerop
(cdr
(assoc
40
(setq
e (entget (tblobjname "STYLE" (getvar 'textstyle)))
)
)
)
)
(* (getvar 'textsize) 2.0)
(* (cdr (assoc 40 e)) 2.0)
)
columns 2
r 2
)
(if (setq ins (getpoint "\n Specify Table Location :"))
(progn
(setq
tbl (vla-addtable
(vlax-get
(vla-get-activelayout
(vla-get-activedocument (vlax-get-acad-object))
)
'BLOCK
)
(vlax-3d-point ins)
(+ (length l) 2)
columns
(* hgt 1.5)
(* hgt 1.5)
)
)
(setq inc -1)
(repeat 2
(vla-setcolumnwidth tbl (setq inc (1+ inc)) (* hgt 5.))
)
(vla-setrowheight tbl 0 (* hgt 1.5))
(vla-setrowheight tbl 1 (* hgt 1.5))
(vla-settext
tbl
0
0
(strcat "Blocks Quantity")
)
(vla-setcolumnwidth tbl 0 (* hgt 10.))
(vla-setcolumnwidth tbl 1 (* hgt 4.5))
(vla-settext tbl 1 0 "Block Name")
(vla-settext tbl 1 1 "QTY")
)
)
(defun WriteAndSet (col row string)
(vla-settext tbl row col string)
(vla-setcellalignment tbl row col acMiddleCenter)
)
(foreach x l
(WriteAndSet 0 r (car x))
(WriteAndSet 1 r (cadr x))
(setq r (1+ r))
)
)
)
(princ)
)
(vl-load-com)