rotate texts around a point

jtm2020hyo
Collaborator
Collaborator

rotate texts around a point

jtm2020hyo
Collaborator
Collaborator

I attached a lisp routine that rotates blocks around a center point.

I need to rotate all kind of texts (text, mtext , rtext , dtext) in the same way that this lisp work.

 

image.png

 

 

 

0 Likes
Reply
Accepted solutions (1)
1,194 Views
6 Replies
Replies (6)

Anonymous
Not applicable
Accepted solution

@jtm2020hyo Test this:

(defun c:R2CP (/ T_Selection T_Point T_OffsetAngle T_Object T_Angle)
   (if
      (and
         (setq T_Selection (ssget '((0 . "TEXT,MTEXT"))))
	 (setq T_Point (getpoint "\nSpecify unique central point : "))
         (not (initget 1))
         (setq T_OffsetAngle (getangle "\nOffset block angle : "))
      )
      (progn
         (vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
         (foreach T_Object (vl-remove-if '(lambda (T_Item) (listp (cadr T_Item))) (ssnamex T_Selection))
            (setq T_Object (vlax-ename->vla-object (cadr T_Object)))         
            (setq T_Angle (angle (vlax-safearray->list (vlax-variant-value (vla-get-InsertionPoint T_Object))) T_Point))
            (vla-put-Rotation T_Object (- T_Angle T_OffsetAngle))
         )
         (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
      )
   )
   (princ)
)

jtm2020hyo
Collaborator
Collaborator

@Anonymous wrote:

@jtm2020hyo Test this:

(defun c:R2CP (/ T_Selection T_Point T_OffsetAngle T_Object T_Angle)
   (if
      (and
         (setq T_Selection (ssget '((0 . "TEXT,MTEXT"))))
	 (setq T_Point (getpoint "\nSpecify unique central point : "))
         (not (initget 1))
         (setq T_OffsetAngle (getangle "\nOffset block angle : "))
      )
      (progn
         (vla-StartUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
         (foreach T_Object (vl-remove-if '(lambda (T_Item) (listp (cadr T_Item))) (ssnamex T_Selection))
            (setq T_Object (vlax-ename->vla-object (cadr T_Object)))         
            (setq T_Angle (angle (vlax-safearray->list (vlax-variant-value (vla-get-InsertionPoint T_Object))) T_Point))
            (vla-put-Rotation T_Object (- T_Angle T_OffsetAngle))
         )
         (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
      )
   )
   (princ)
)


 

What about RTEXT , DTEXT ? 


Do I need to add those to code like this? :

         (setq T_Selection (ssget '((0 . "TEXT,MTEXT,RTEXT,DTEXT"))))

@Anonymous

Anonymous
Not applicable

@jtm2020hyo  RTEXT is an Express Tool so it will not work.

 

Kent1Cooper
Consultant
Consultant

@jtm2020hyo wrote:
....

What about RTEXT , DTEXT ? 

Do I need to add those to code like this? :

         (setq T_Selection (ssget '((0 . "TEXT,MTEXT,RTEXT,DTEXT"))))

@Frjuniornogueira wrote:

RTEXT is an Express Tool so it will not work.

------------------

 

First of all, there is no such entity type as DTEXT.  It's an old command  name from  w a y ,  w a y   back, but the TEXT command for many years  now has done what DTEXT does [I think the DTEXT command name is only kept around for legacy reasons], instead of working the way TEXT used to work when DTEXT was first introduced to overcome some of TEXT's original limitations [primarily, not seeing what you were getting until you finished entering the content -- the D is for Dynamic, meaning it appears on-screen as you type].  But throughout history, the entity type made by the DTEXT command was and is just TEXT -- DTEXT not only isn't now, but has never been, an entity type in AutoCAD, so forget about including it in an (ssget) filter list.

 

Secondly, the RTEXT operation  [to add some to a drawing] may be an Express Tool, but the resulting entity  in the drawing has Rotation just like anything else -- it has a Rotation VLA Property, and an (assoc 50) entry in entity data -- so a routine that Rotates things should be able to work with Rtext just as it does with Blocks and Text and Mtext.

 

Without having studied the suggested routine in detail, I will hazard a guess that you should be able to do:

  (setq T_Selection (ssget '((0 . "*TEXT"))))

and cover all bases.

Kent Cooper, AIA

jtm2020hyo
Collaborator
Collaborator

@Kent1Cooper wrote:

@jtm2020hyo wrote:
....

What about RTEXT , DTEXT ? 

Do I need to add those to code like this? :

         (setq T_Selection (ssget '((0 . "TEXT,MTEXT,RTEXT,DTEXT"))))

@Frjuniornogueira wrote:

RTEXT is an Express Tool so it will not work.

------------------

 

First of all, there is no such entity type as DTEXT.  It's an old command  name from  w a y ,  w a y   back, but the TEXT command for many years  now has done what DTEXT does [I think the DTEXT command name is only kept around for legacy reasons], instead of working the way TEXT used to work when DTEXT was first introduced to overcome some of TEXT's original limitations [primarily, not seeing what you were getting until you finished entering the content -- the D is for Dynamic, meaning it appears on-screen as you type].  But throughout history, the entity type made by the DTEXT command was and is just TEXT -- DTEXT not only isn't now, but has never been, an entity type in AutoCAD, so forget about including it in an (ssget) filter list.

 

Secondly, the RTEXT operation  [to add some to a drawing] may be an Express Tool, but the resulting entity  in the drawing has Rotation just like anything else -- it has a Rotation VLA Property, and an (assoc 50) entry in entity data -- so a routine that Rotates things should be able to work with Rtext just as it does with Blocks and Text and Mtext.

 

Without having studied the suggested routine in detail, I will hazard a guess that you should be able to do:

  (setq T_Selection (ssget '((0 . "*TEXT"))))

and cover all bases.




 

what you say sound very interesting. Is possible to use regular-expressions on LISP routines?

0 Likes

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

 ... RTEXT ... has Rotation just like anything else -- it has a Rotation VLA Property, and an (assoc 50) entry in entity data ....


 

However, after putting some RTEXT into a drawing and looking into it, I find that while the rotation in the (assoc 50) entry in entity data for it is in radians, just as it is for Blocks and Text and Mtext, the VLA Rotation Property for it  [very oddly and surprisingly, it seems to me] is stored in degrees!  [For all those other entity types, that's also in radians.]  Probably related to that oddity is the fact that its Rotation in the Properties palette is shown in length  terms rather than angular terms [even in feet and inches  when in Imperial units -- 90-degree rotation shows there as 7'-6"]!

 

So if you're including Rtext in a selection, I guess you should either alter rotations of things using (subst)/(entmod) methods with entity data instead [since that should work right for all entity types], or you should check for the entity type of individual objects in stepping through the selection, and for Rtext only, convert the radians value to degrees before applying it as the Rotation Property.

Kent Cooper, AIA