@adaptacad ,
Try this. Hope it helps.
(defun c:TEST ( / osm cmd ss e eg txt tmp cnt cntGood cntBad num p)
(vl-load-com)
;if no text items, exit routine
(if (not (setq ss (ssget "_X" '((0 . "TEXT") (8 . "apartments") (410 . "Model")))))
(progn (prompt "\nNo text objects found on \"apartment\" layer...") (exit))
);if
;prepare for loop
(setq osm (getvar 'OSMODE) cmd (getvar 'CMDECHO))
(setvar 'OSMODE (logior 16384 osm)) (setvar 'CMDECHO 0)
(setq cnt (sslength ss) cntGood 0 cntBad 0)
;loop through ss
(while (>= (setq cnt (1- cnt)) 0)
(setq e (ssname ss cnt)
eg (entget e)
txt (cdr (assoc 1 eg)))
;only continue if we find first letter "A", and initial text is a number
(if (and (setq tmp (vl-string-search "A" txt))
(setq txt (substr txt 1 tmp))
(distof txt 2))
(progn
(setq num (atoi txt))
;use cond to determine what text will be used in block
(cond
((< num 6) (setq num nil))
((<= 6 num 10) (setq num "1"))
(t (setq num (itoa (+ 2 (fix (/ (1- (- num 10)) 8))))))
);cond
;only continue if block is needed and found
(if (and num (tblsearch "BLOCK" "highlighter"))
(progn
(setq p (cdr (assoc 11 eg)))
(command "-INSERT" "highlighter" "_scale" 1 p 0)
(setpropertyvalue (entlast) "QUANTIDADE" num)
(setq cntGood (1+ cntGood))
);progn
;otherwise, it's a bad count
;else
(setq cntBad (1+ cntBad))
);if
);progn
;otherwise, it's a bad count
;else
(setq cntBad (1+ cntBad))
);if
;prep for next iteration (not totally required)
(setq txt nil eg nil num nil)
);while
;finishing touches/cleanup
(setq ss nil)
(setvar 'OSMODE osm) (setvar 'CMDECHO cmd)
(prompt (strcat "\nCompletion Status:\n"
(itoa cntBad) " - Ignored Text Items\n"
(itoa cntGood) " - Successful Text Items\n"))
(princ)
);defun
Best,
~DD