Created according to your sample not using lee mac script.
Code asks you to select object on the layer where rooms borders (walls) are created and extracts its layer name.
It collects all closed polyline inside that layer and for each polyline in selection extracts its area perimeter(length) and coordinates. Inside polygon defined by this coordinates it search for a text (mtext) object inside same layer as selected polyline. Than it creates table from point you pick. Scale table according to your needs, I didn't put table styling inside code.
(defun c:LuciLopes ( / *error* take pointlist2d JH:list-to-table lay room_list room_name rooms_ss i spaceobject eo area len pts sst)
(defun *error* (msg)
(if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*"))
(princ (strcat "\nOops an Error : ( " msg " ) occurred."))
)
(princ)
)
(defun take (amount lst / ret)(repeat amount (setq ret (cons (car lst) (take (1- amount) (cdr lst))))))
(defun pointlist2d (lst / ret) (while lst (setq ret (cons (take 2 lst) ret) lst (cddr lst))) (reverse ret))
;; JH:list-to-table --> Jonathan Handojo
;; Creates a table from a list of lists of strings
;; space - ModelSpace or Paperspace vla object
;; lst - list of lists where each list is a list of strings
;; => if you wish to insert a block in the cell, prefix using "<block>" followed by the block name
;; => e.x. if you want to insert the block "TestBlock1", input the string as "<block>TestBlock1"
;; pt - Insertion point of table (2 or 3 reals)
;; tblstyle - Table style to use
(defun JH:list-to-table (space lst pt tblstyle / i j lens ncols rows totlen txt vtable)
(setq ncols (apply 'max (mapcar 'length lst))
vtable (vla-AddTable space (vlax-3d-point pt) (length lst) ncols 10 10)
)
(vla-put-RegenerateTableSuppressed vtable :vlax-true)
(vla-put-StyleName vtable tblstyle)
(repeat (setq i (length lst))
(setq rows (nth (setq i (1- i)) lst))
(vla-SetRowHeight vtable i (* 2 (vlax-invoke vtable 'GetCellTextHeight i 0)))
(repeat (setq j (length rows))
(setq lens
(cons
(+
(abs
(apply '-
(mapcar 'car
(textbox
(list
(cons 1 (setq txt (nth (setq j (1- j)) rows)))
(cons 40 (vlax-invoke vtable 'GetCellTextHeight i j))
(cons 7 (vlax-invoke vtable 'GetCellTextStyle i j))
)
)
)
)
)
(vlax-invoke vtable 'GetCellTextHeight i j)
)
lens
)
)
(if (eq (strcase (substr txt 1 7)) "<BLOCK>")
(progn
(setq blk (substr txt 8))
(if (and
(wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*")
(vlax-method-applicable-p vtable 'setblocktablerecordid32)
)
(vla-SetBlockTableRecordId32 vtable i j (vla-get-ObjectID (vla-item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) blk)))
(vla-SetBlockTableRecordId vtable i j (vla-get-ObjectID (vla-item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) blk)) :vlax-true)
)
)
(vla-SetText vtable i j txt)
)
)
(setq totlen (cons lens totlen) lens nil)
)
(repeat ncols
(vla-SetColumnWidth vtable (setq ncols (1- ncols))
(apply 'max
(vl-remove nil
(mapcar
'(lambda (x)
(nth ncols x)
)
totlen
)
)
)
)
)
(vla-put-RegenerateTableSuppressed vtable :vlax-false)
vtable
)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq spaceobject(if (eq (getvar 'cvport) 1)(vla-get-paperspace doc)(vla-get-modelspace doc)))
(setq lay (cdr(assoc 8 (entget(car(entsel "\nSelect closed lwpolyline on layer whos entity areas needs to be extracted >"))))))
(setq rooms_ss (ssget "_X" (list (cons 0 "lwpolyline")(cons 8 lay) (cons 70 1))))
(cond
((and rooms_ss)
(setq i -1)
(setq room_list (list))
(setq room_list (append room_list (list(list "TABELA DE ÁREA"))))
(setq room_list (append room_list (list(list "CÔMODO" "ÁREA" "PERIMETRO"))))
(while (< (setq i (1+ i)) (sslength rooms_ss))
(setq eo (vlax-ename->vla-object (ssname rooms_ss i)))
(setq area (rtos (vlax-get eo 'Area)2 2) len (rtos(vlax-get eo 'Length)2 2))
(setq pts (pointlist2d (vlax-get eo 'coordinates)))
(setq sst (ssget "wp" pts (list (cons 8 lay) (cons 0 "*TEXT"))))
(setq room_name (cdr (assoc 1 (entget (ssname sst 0)))))
(setq room_list (append room_list (list(list room_name area len))))
)
(setq pt (getpoint "\nSelect table insertion point >"))
(JH:list-to-table spaceobject room_list pt "standard")
(princ "\nDone!")
)
)
(princ)
)
Miljenko Hatlak

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.