Rotate & Move Text

Rotate & Move Text

john.uhden
Mentor Mentor
2,134 Views
15 Replies
Message 1 of 16

Rotate & Move Text

john.uhden
Mentor
Mentor

We waste so much time adjusting little text labels, mainly spot elevations.

So I made this up this morning...

Enjoy, OR ELSE!

(defun C:R+M ( / *error* vars vals e obj objname ip rot)
   ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
   ;*                                                                           *
   ;*         R+M.LSP    by     John F. Uhden                                   *
   ;*                           2 Village Road                                  *
   ;*                           Sea Girt, NJ  08750                             *
   ;*                                                                           *
   ;* * * * * * * * * * * *  Do not delete this heading!  * * * * * * * * * * * *

   ; Program combines rotating and moving text/mtext objects just to save time
   ; adjusting their position for neatness and legibility.

   ; v1.0 (01-17-2020) made for Challoner

   (gc)
   (prompt "\nR+M v1.0 (c)2020, John F. Uhden")
   (defun *error* (error)
      (sssetfirst)
      (mapcar 'setvar vars vals)
      (vla-endundomark *doc*)
      (cond
        (not error)
        ((wcmatch (strcase error) "*CANCEL*,*QUIT*")
          (vl-exit-with-error "\r                                              ")
        )
        (1 (vl-exit-with-error (strcat "\r*ERROR*: " error)))
      )
      (princ)
   )
   ;;------------------------------------------
   ;; Intitialize drawing and program variables:
   ;;
   (setq *acad* (vlax-get-acad-object))
   (setq *doc* (vlax-get *acad* 'ActiveDocument))
   (vla-endundomark *doc*)
   (vla-startundomark *doc*)
   (setq vars '("cmdecho" "highlight"))
   (setq vals (mapcar 'getvar vars))
   (mapcar 'setvar vars '(0 1))
   (command "_.expert" (getvar "expert")) ;; dummy command

   (while (setq e (car (entsel "\nSelect text object to rotate/move: ")))
     (setq obj (vlax-ename->vla-object e)
           objname (vlax-get obj 'ObjectName)
     )
     (and
       (or
         (wcmatch (strcase objname) "*TEXT")
         (prompt "\nObject selected is not text.")
       )
       (setq ip (vlax-get obj 'InsertionPoint))
       (setq rot (vlax-get obj 'Rotation))
       (princ "\nNew rotation: ")
       (vl-cmdf "_.rotate" e "" "_non" ip "_R" (angtos rot 0 4))
       (while (> (getvar "cmdactive") 0)(vl-cmdf pause) 1)
       (princ "\nNew position: ")
       (vl-cmdf "_.move" e "" "_non" ip)
       (while (> (getvar "cmdactive") 0)(vl-cmdf pause) 1)
     )
   )
   (*error* nil)
)
(defun c:RM ()(c:R+M))

John F. Uhden

2,135 Views
15 Replies
Replies (15)
Message 2 of 16

ronjonp
Mentor
Mentor

Nice 🙂 .. could this be taken a step further and not require the user to manually 'cleanup' the label? Post a sample drawing!

0 Likes
Message 3 of 16

john.uhden
Mentor
Mentor
As to taking it a step further, probably not in reality.
Whether it's Land Desktop or C3D, field shots are imported and there's no
choice of angle.
I wrote a routine to convert them to points and text (the way the boss
likes it), but then as say curb lines wander down the curvy road or around
the site, we want to rotate and shift pieces of text, one by one, to make
the plan neat and legible.
Thank goodness I wrote it this morning bc this afternoon I am cleaning up
about a thousand spot shots. It's going very well; almost done

I am too embarrassed to post a 2004 dwg. You gotta try it yourself to see
if it's worth anything to you.

John F. Uhden

0 Likes
Message 4 of 16

devitg
Advisor
Advisor

Hi John, what's the difference with MOCORO command . 

0 Likes
Message 5 of 16

john.uhden
Mentor
Mentor
I don't know that I even have it. We are running LDT 2004.
I do know that I don't need the COpy part.

John F. Uhden

0 Likes
Message 6 of 16

devitg
Advisor
Advisor

You can use MO RO , no CO 

 

 

Command: MOCORO

Select objects: 1 found

Select objects:

Base point:
[Move/Copy/Rotate/Scale/Base/Undo]<eXit>: M

Second point of displacement:
[Move/Copy/Rotate/Scale/Base/Undo]<eXit>: R

Second Point or Rotation angle:
[Move/Copy/Rotate/Scale/Base/Undo]<eXit>:
0 Likes
Message 7 of 16

Sea-Haven
Mentor
Mentor

Sorry for John

 

Yeah civ3d can be a pain, a block after reducing data is not at correct angle so, rotate civ3d point, want to label one or more Civ3d point for height handy when designing roads to see level but not see hundreds. label set out pts come to mind to make readable, spent a lot of time doing that. 

 

 

0 Likes
Message 8 of 16

dbroad
Mentor
Mentor

Thanks John.  Hope things are going well.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 9 of 16

Sea-Haven
Mentor
Mentor

"Whether it's Land Desktop or C3D, field shots are imported and there's no choice of angle."

 

One of the things I have done for civ3d is take advantage of a double code I have used this for trees where you have a spread and trunk. You reduce as normal and end up with a block for the tree. I read the code the two parts and adjust the dynamic tree block to reflect the values. 

 

;RawDescription = "TR 5 1.5" replace tr as required add extra tree types also.

 

So theoretically you could add in the field survey an angle reading the cogo point if it has a rotation code then rotate Civ3d point. Maybe dump the cogo points into excel mod the points you want then use point number to change. Perhaps some form of options this could be a can of worms.

 

I did something over at Cadtutor that used rotate to line angle can find again.

 

The data recorders are getting smarter so a code TEL 45 would be remembered till changed to say plain TEL ie default angle the lisp would rotate to 45.   LabelRotation = 0.785398 this is a property of a point.

 

 

0 Likes
Message 10 of 16

Sea-Haven
Mentor
Mentor

I think you could do pick pline, and then select cogo points same code and rotate to a known angle relative to pline. So change multiples in one go. Is this what your thinking of ?

 

In this image the elev's would not rotate around the pline as it follows the road, the label is smart enough to be "readable" at all times. Will have a go at something in between other projects.

 

screenshot144.png

0 Likes
Message 11 of 16

john.uhden
Mentor
Mentor

That's a noble idea.  Sadly, I have to adjust each spot label one-at-a-time to fit next to other linework, symbols, and labels.  So what I cooked up is almost perfect.  The only annoying thing is that once you point to the new rotation, your cursor is away from the insertion point so when it invokes the move command you have to move your cursor sorta back near where you started.  I don't think there's any way in AutoLisp that you can programatically (sp?) adjust a cursor's location.  Anyway, a rotate and a move with only two picks (and no additional keyboard input) is pretty sweet to me.

Well I guess I could control the rotation by using grread and the + and - keys, but if you use the same hand to operate the mouse and the keyboard, there's really no advantage to that idea.

My apologies... I think I have wasted a lot of people's time.

John F. Uhden

0 Likes
Message 12 of 16

Sea-Haven
Mentor
Mentor

The rotation is easy its a label rotate, when you move a cogo point it adopts a leader style, like a lot of other things in CIV3D you have to look elsewhere, saying that not finding answer, you can get the Point, and it reflects the angle, but not leader details. I notice there is a "move label" option so mabye there is a way to execute this command. Will look further.

0 Likes
Message 13 of 16

john.uhden
Mentor
Mentor
Thanks, but don't look on my behalf.
We are still using Land Desktop 2004.

John F. Uhden

0 Likes
Message 14 of 16

Sea-Haven
Mentor
Mentor

Its till a bit long winded in CIV3d 2020. But can do no code.screenshot147.png

 

0 Likes
Message 15 of 16

amhere
Explorer
Explorer

Thanks John,

That is amazing!

Please help me. I edit so that I can select a group of objects, then select text or block to determine the original angle, then rotate to the new angle, and move to the new position.
But because I'm not proficient in Lisp, the code I edited is very bad.

The rows I edited are noted with: ;;; --- EDIT --- ;;;
Can you help me?

(defun C:R+M ( / *error* vars vals e obj objname ip rot sstemp)     ;;; --- EDIT --- ;;;
   ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
   ;*                                                                           *
   ;*         R+M.LSP    by     John F. Uhden                                   *
   ;*                           2 Village Road                                  *
   ;*                           Sea Girt, NJ  08750                             *
   ;*                                                                           *
   ;* * * * * * * * * * * *  Do not delete this heading!  * * * * * * * * * * * *

   ; Program combines rotating and moving text/mtext objects just to save time
   ; adjusting their position for neatness and legibility.

   ; v1.0 (01-17-2020) made for Challoner

   (gc)
   (prompt "\nR+M v1.0 (c)2020, John F. Uhden")
   (defun *error* (error)
      (sssetfirst)
      (mapcar 'setvar vars vals)
      (vla-endundomark *doc*)
      (cond
        (not error)
        ((wcmatch (strcase error) "*CANCEL*,*QUIT*")
          (vl-exit-with-error "\r                                              ")
        )
        (1 (vl-exit-with-error (strcat "\r*ERROR*: " error)))
      )
      (princ)
   )
   ;;------------------------------------------
   ;; Intitialze drawing and program variables:
   ;;
   (setq *acad* (vlax-get-acad-object))
   (setq *doc* (vlax-get *acad* 'ActiveDocument))
   (vla-endundomark *doc*)
   (vla-startundomark *doc*)
   (setq vars '("cmdecho" "highlight"))
   (setq vals (mapcar 'getvar vars))
   (mapcar 'setvar vars '(0 1))
   (command "_.expert" (getvar "expert")) ;; dummy command
	(prompt "\nSelect Group of objects to rotate/move: ")     ;;; --- EDIT --- ;;;
	(setq sstemp (ssget))     ;;; --- EDIT --- ;;;
   (while (setq e (car (entsel "\nSelect text object to rotate/move: ")))
     (setq obj (vlax-ename->vla-object e)
           objname (vlax-get obj 'ObjectName)
     )
     (and
     ;;; --- EDIT --- ;;;
	 ;(or
        ; (wcmatch (strcase objname) "*TEXT")
         ;(prompt "\nObject selected is not text.")
       ;)
       (setq ip (vlax-get obj 'InsertionPoint))
       (setq rot (vla-get-rotation obj));(vlax-get obj 'Rotation));     ;;; --- EDIT --- ;;;
       (princ "\nNew rotation: ")
       (vl-cmdf "_.rotate" sstemp "" "_non" ip "_R" (angtos rot 0 4))
       (while (> (getvar "cmdactive") 0)(vl-cmdf pause) 1)
       (princ "\nNew position: ")
       (vl-cmdf "_.move" sstemp "" "_non" ip)
       (while (> (getvar "cmdactive") 0)(vl-cmdf pause) 1)
     )
   )
   (*error* nil)
)
(defun c:RM ()(c:R+M))

 

0 Likes
Message 16 of 16

amhere
Explorer
Explorer

I'm sorry.

Contents duplicated!

0 Likes