(defun C:ADDTAB (/ ss lista2d arealist index ename listpoint pointtable objtable)
(if (not (setq ss (ssget '((0 . "LWPOLYLINE")(8 . "BOUNDARY")))))
(vl-exit-with-error "")
)
(defun lista2d (lst)
(if lst
(cons (list (car lst) (cadr lst))
(lista2d (cddr lst))
)
)
)
(setq arealist '())
(repeat (setq index (sslength ss))
(setq ename (ssname ss (setq index (1- index))))
(setq listpoint (lista2d (safearray-value (variant-value (vla-get-Coordinates (vlax-ename->vla-object ename))))))
(if (not (setq sstext (ssget "_WP" listpoint '((0 . "MTEXT")(8 . "TABLE TEXT")))))
(ssdel ename ss)
(setq arealist (cons (list (vla-get-Textstring (vlax-ename->vla-object (ssname sstext 0))) (vla-get-Area (vlax-ename->vla-object ename))) arealist))
)
)
(setq pointtable (getpoint "\nSelect point insertion table: ")
objtable (vla-AddTable (vla-get-modelspace (vla-get-ActiveDocument (vlax-get-acad-object))) (vlax-3d-Point pointtable) (+ 2 (sslength ss)) 2 6 17)
index 0
)
(vla-SetText objtable index 0 "AREA TABLE")
(vla-SetCellTextHeight objtable index 0 2.40)
(vla-SetCellAlignment objtable index 0 acMiddleCenter)
(vla-SetText objtable (setq index (1+ index)) 0 "PLOT NO.")
(vla-SetCellTextHeight objtable index 0 2.10)
(vla-SetCellAlignment objtable index 0 acMiddleCenter)
(vla-SetText objtable index 1 "AREA")
(vla-SetCellTextHeight objtable index 1 2.10)
(vla-SetCellAlignment objtable index 1 acMiddleCenter)
(foreach elem arealist
(vla-SetText objtable (setq index (1+ index)) 0 (car elem))
(vla-SetCellTextHeight objtable index 0 2.40)
(vla-SetCellAlignment objtable index 0 acMiddleCenter)
(vla-SetText objtable index 1 (rtos (cadr elem) 2 3))
(vla-SetCellTextHeight objtable index 1 2.10)
(vla-SetCellAlignment objtable index 1 acMiddleCenter)
)
)
This should be fine. The programme selects the polylines on the BOUNDARY layer, the vertices of the polylines act as a selection for any text inside. If there is no text, the polyline is deleted from the selection set, otherwise a list is created with the text string and the corresponding polyline area. The rest is easy, the table is created with the list data in the AREALIST variable.