I would add a filter just in case a user applies the function twice.
Judging by the number of unused variables and unnecessary code, I think you have pasted sections from an existing function...
The code below works. But there is an important limitation. The dimensions for rectangular columns that are not orthogonal will be wrong.
(defun c:ColumnsSizes () (c:CSZ))
(defun c:CSZ ( / mn mx peditaccept plinecnt pntnX pntxX ss)
(vl-load-com)
(if ;(setq ss (ssget "_X" '((0 . "ARC,LINE"))))
(setq ss (ssget "_X" '((0 . "ARC,LINE,LWPOLYLINE"))))
(progn
(setq peditaccept (getvar 'peditaccept))
(setvar 'peditaccept 1)
(command "_.pedit" "_M" ss "" "_J" "" "")
(setvar 'peditaccept peditaccept)
)
)
(setq plinecnt 0)
(if (setq ss (ssget "_X" '((0 . "LWPOLYLINE"))))
(repeat (sslength ss)
(vla-getboundingbox (vlax-ename->vla-object (ssname ss plinecnt)) 'mn 'mx)
(setq mn (vlax-safearray->list mn))
(setq mx (vlax-safearray->list mx))
(setq pntnX (nth 0 mn)) (setq pntnY (nth 1 mn))
(setq pntxX (nth 0 mx)) (setq pntxY (nth 1 mx))
(InsText (strcat "Size" (rtos (- pntxX pntnX) 2 1) " x " (rtos (- pntxY pntnY) 2 1)) (list pntxX pntnY 0.0))
(setq plinecnt (1+ plinecnt))
)
)
)
(defun InsText ( BlkName pt / )
(entmakex
(list
(cons 0 "TEXT")
(cons 8 "Defpoints")
(cons 1 BlkName)
(cons 10 Pt)
(cons 40 100)
(cons 41 0.8)
)
)
)
(princ "\n Type CSZ to invoke the lisp ")
(princ)