According to BeekeeCZ, the "text" command varies its parameters depending on whether the current text style has height 0 or not.
A possible solution would be "test1", but we can not choose text height if the style has height > 0.
(defun c:test1 ( / p1 hTxt RotTxt)
(setq p1 (getpoint "\nInsertion point of text: "))
(setq hTxt 2.5)
(setq RotTxt 0.0)
(if (zerop (cdr (assoc 40 (tblsearch "style" (getvar 'textstyle)))))
(command "_.text" p1 hTxt RotTxt "Text height 0 in style")
;;else:
(command "_.text" p1 RotTxt "Text with height > 0 in style")
)
(princ)
)
I personally would use "entmake" or "entmakex" as in the following illustration:
;;------------------ jlgg-Make_Txt ----------------------------;;
;; Jose Luis García G. ;;
;; Draws a text on the screen ;;
;; Code h. Code v. ;;
;; --------- ------------ ;;
;; 0 = left 1 = bottom ;;
;; 1 = center 2 = medium ;;
;; 2 = right 3 = upper ;;
;;-------------------------------------------------------------;;
(defun jlgg-Make_Txt (sLay IndexColor Style heightTxt RotTxt PtInsTxt sText codh codv
/ style eTxt UCSAngX
)
(defun UCSAngX ( / vec)
(setq vec (getvar 'ucsxdir))
(atan (cadr vec) (car vec))
);c.defun
;;---------------- MAIN --------------------
(if (not
(and style
(= (type Style) 'STR)
(tblsearch "STYLE" Style)))
(setq style (getvar 'textstyle))
)
(setq eTxt
(entmakex
(list '(0 . "TEXT")
(if sLay (cons 8 sLay)(cons 8 (getvar "CLAYER")))
(if IndexColor (cons 62 IndexColor) (cons 62 256))
(if heightTxt (cons 40 heightTxt)(cons 40 (getvar 'textsize)))
(cons 1 sText)
(if RotTxt (cons 50 (+ (UCSAngX) RotTxt)) (cons 50 (UCSAngX)))
'(41 . 1.0)
(cons 7 Style)
(cons 72 codh)
(cons 73 codv)
(cons 10 PtInsTxt)
(cons 11 PtInsTxt)
)
)
)
eTxt
)
(defun c:test2 ( / p1 hTxt RotTxt)
(setq hTxt 2.5)
(or idx (setq idx 1))
(while (setq p1 (getpoint "\nInsertion point of text: "))
(jlgg-Make_Txt nil idx nil hTxt nil p1
(strcat "Text " (itoa idx) " with height independent of the style")
1 2
)
(setq idx (if (= 255 idx) 1 (1+ idx)))
)
(princ)
)
regards..