TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Craig on September 07, 2005, 12:55:53 PM

Title: Text Rotation
Post by: Craig on September 07, 2005, 12:55:53 PM
Does anyone know what the variable for text rotation is?

Something like (getvar 'textsize) but for the text rotation/angle

TIA
Title: Re: Text Rotation
Post by: tombu on September 07, 2005, 01:13:39 PM
Having spent too much time looking for it I'm pretty sure there isn't one.  Please someone tell me I'm wrong.
Title: Re: Text Rotation
Post by: CottageCGirl on September 07, 2005, 01:40:48 PM
^C^C-attedit;;;;;\;P;\A;\N;

sorry, havent had time to fully explore the new ins and outs of the new stuff
Title: Re: Text Rotation
Post by: CottageCGirl on September 07, 2005, 01:42:10 PM
ooops sorry, I'm in block mode, thats the move/rotate for attributes (maybe someone can still use it) :oops:
Title: Re: Text Rotation
Post by: Craig on September 07, 2005, 01:45:25 PM
I find it hard to believe that it shows up in a list but it's not accessible as some type of variable.

What I want is I've written a program that places an identifier on a line with the distance of the selected line and places the text at a certain distance off the line, at the angle of the line and in the middle of it. What I need is to be able to reset the text rotation back to zero. It seems fairly simple thing to do but in my searching I've yet to find anything that will do this.
Title: Re: Text Rotation
Post by: Craig on September 07, 2005, 01:52:30 PM
Thinkg more I guess a work around is to place the text at zero and auto rotate it to the correct angle. Not what I want to do but if no else has an answer I guess it will have to do.  :?
Title: Re: Text Rotation
Post by: Craig on September 07, 2005, 02:02:46 PM
This worked fine even though it's not what I wanted to do.
Code: [Select]
(command "text" "bl" mecGetPoint mecTxtSize "0" mecLineLength)
(command "rotate" "l" "" mecGetPoint mecAngle)
Title: Re: Text Rotation
Post by: Crank on September 07, 2005, 02:25:13 PM
This worked fine even though it's not what I wanted to do.
Code: [Select]
(command "text" "bl" mecGetPoint mecTxtSize "0" mecLineLength)
(command "rotate" "l" "" mecGetPoint mecAngle)
Try this:
Code: [Select]
(command ".text" "bl" mecGetPoint mecTxtSize mecAngle mecLineLength)
Title: Re: Text Rotation
Post by: LE on September 07, 2005, 02:28:52 PM
Hi,

See if this quick code does what you are looking for.

Load the code in your drawing session, type any text or mtext and use: (get_txtrot_angle)
To read the rotation angle.

HTH

Code: [Select]
(vl-load-com)

(if (not (getenv "TextRotationAngle"))
  (setenv "TextRotationAngle" "0.0"))

(defun savetxtrotangle (reactor params / ename obj)
  (if (and (wcmatch (car params) "TEXT,MTEXT")
   (setq ename (entlast))
   (wcmatch (cdadr (entget ename)) "TEXT,MTEXT"))
    (progn
      (setq obj (vlax-ename->vla-object ename))
      (setenv "TextRotationAngle"
      (rtos (vla-get-rotation obj) 2 8)))))

(if (not text_rotation_angle_reactor)
  (setq text_rotation_angle_reactor
(vlr-editor-reactor
   "text rotation angle"
   '((:vlr-commandended . savetxtrotangle)))))

(defun rtd (a) (* (/ a pi) 180.0))

(defun get_txtrot_angle ()
  (rtd (atof (getenv "TextRotationAngle"))))

(princ)
Title: Re: Text Rotation
Post by: Craig on September 07, 2005, 03:00:05 PM
This worked fine even though it's not what I wanted to do.
Code: [Select]
(command "text" "bl" mecGetPoint mecTxtSize "0" mecLineLength)
(command "rotate" "l" "" mecGetPoint mecAngle)
Try this:
Code: [Select]
(command ".text" "bl" mecGetPoint mecTxtSize mecAngle mecLineLength)


Thats the way I had it at the start. Thats the reason for this thread, to be able to set the text rotation back to zero. If I use the one you show the text is set to that angle throughout the session unless I manually change it.

All I wanted was to set the text rotation to zero after using something like
Code: [Select]
(command ".text" "bl" mecGetPoint mecTxtSize mecAngle mecLineLength)
(setvar 'textrotation 0)

even though that variable does not exist
Title: Re: Text Rotation
Post by: Bob Wahr on September 07, 2005, 03:01:32 PM
you could put your text in along the line, then put in a piece of text at 0 and erase it.  Sloppy, ugly, nasty, but as a last resort.
Title: Re: Text Rotation
Post by: LE on September 07, 2005, 03:03:52 PM
Quote
All I wanted was to set the text rotation to zero....

O....I shoud read first....
Title: Re: Text Rotation
Post by: Craig on September 07, 2005, 03:07:08 PM
you could put your text in along the line, then put in a piece of text at 0 and erase it.  Sloppy, ugly, nasty, but as a last resort.
Thanks, this works fine, just didn't want it that way

Code: [Select]
(command "text" "bl" mecGetPoint mecTxtSize "0" mecLineLength)
(command "rotate" "l" "" mecGetPoint mecAngle)
Title: Re: Text Rotation
Post by: Craig on September 07, 2005, 03:08:14 PM
Quote
All I wanted was to set the text rotation to zero....

O....I shoud read first....

Thanks for the replies
Title: Re: Text Rotation
Post by: CAB on September 07, 2005, 04:04:49 PM
Here is one way to set text angle to zero.
Code: [Select]
(defun c:txt2ang0 (/ ss i obj ename)
  (vl-load-com)
  (prompt "\nSelect text to change angle to zero")
  (and (setq ss (ssget '((0 . "TEXT,MTEXT"))))
       (setq i -1)
       (while (setq ename (ssname ss (setq i (1+ i))))
         (setq obj (vlax-ename->vla-object ename))
         (vlax-put-property obj 'Rotation 0.0)
       )
  )
  (princ)
)
Title: Re: Text Rotation
Post by: CAB on September 07, 2005, 04:14:24 PM
OK, here is another version, single select.

Code: [Select]
(defun c:txt2ang0 (/ obj ent)
  (vl-load-com)
  (and
    (setq ent (entsel "\nSelect text to change angle to zero"))
    (member (cdr (assoc 0 (entget (car ent)))) '("TEXT" "MTEXT"))
    (setq obj (vlax-ename->vla-object (car ent)))
    (vlax-put-property obj 'Rotation 0.0)
  )
  (princ)
)