Certain drawing does not allow rotation in (command "text")

Certain drawing does not allow rotation in (command "text")

Anonymous
Not applicable
841 Views
2 Replies
Message 1 of 3

Certain drawing does not allow rotation in (command "text")

Anonymous
Not applicable

Hi

 

I have a drawing which does not allow the user to add a rotation for the text? I have attached the drawing in case you wanna look.

 

If I run the (command "text") function with all the parameters, say, (command "text" p 1.0 0 "hello"), autocad will put a "0" for the text? If I say, (command "text" p 1.0 "hello"), it will put "hello" and not ask for its rotation. I have never seen this before? What is going on?

 

Thanks

 

Derryck

0 Likes
Accepted solutions (1)
842 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution
You did not attach the file.
But this issue is probably a TEXTSTYLE related. Check the current text style and see if the text HEIGTH is set 0 or not. And see the difference if you change the value.
Message 3 of 3

joselggalan
Advocate
Advocate

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..

 

0 Likes