Author Topic: Quick rotate and / or move-rotate  (Read 3910 times)

0 Members and 1 Guest are viewing this topic.

R_rogerD

  • Guest
Quick rotate and / or move-rotate
« on: July 27, 2015, 02:38:31 PM »
Hi all,

I had great success on here last time I tried a few months back.. thanks Lee Mac.

http://www.theswamp.org/index.php?topic=49446.msg545839#msg545839

What I need this time is something very similar and hopefully, won't take too much to change the last offering.. :-) Any takers?

 
I am after a couple of commands please if anyone knows of them, to:
 
1) Quick rotate text - in other words, simply click the text and click somewhere in space to rotate it. It will always automatically use it's insert point as the base point. and:
 
2) Quick move and rotate - similarly, select text, place somewhere, then click in space for it's orientation. Always using insert point as base point. IE without having to move/enter/select/enter/base point/destination/rotate/enter/base/rotation.

Grip editing doesn't really do it as still too cumbersome, unless I am doing something wrong  :|
 
If anyone can help, that would certainly be great!
 
Thanks :-)
 
Rroger_D


chauhuh

  • Guest
Re: Quick rotate and / or move-rotate
« Reply #1 on: July 27, 2015, 03:55:51 PM »
argh, help please?

how come
Code: [Select]
(cdr (assoc 10 (entget s))) doesn't work?

Code: [Select]
(defun c:rotatetextfrominsert (/ s en e)
  (if (and (setq s (entsel "\nSelect any TEXT or MTEXT: "))
   (wcmatch (setq en (cdr (assoc 0 (setq e (entget (car s))))))
    "*TEXT"
   )
      )
    (progn
      (command "rotate" s (cdr (assoc 10 (entget s))) pause)
    )
    (prompt "\nObject is not a TEXT or MTEXT.")
  )
  (princ)
)

Thanks.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Quick rotate and / or move-rotate
« Reply #2 on: July 27, 2015, 04:42:30 PM »
Quickly written:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:rt ( / s )
  2.     (if (setq s (ssget "_+.:E:S:L" '((0 . "TEXT"))))
  3.         (progn
  4.             (vl-cmdf "_.rotate" s "" "_non" (txtins (entget (ssname s 0))))
  5.             (while (= 1 (logand 1 (getvar 'cmdactive))) (vl-cmdf "\\"))
  6.         )
  7.     )
  8.     (princ)
  9. )
  10. (defun c:mrt ( / e s )
  11.     (if (setq s (ssget "_+.:E:S:L" '((0 . "TEXT"))))
  12.         (progn
  13.             (setq e (ssname s 0))
  14.             (vl-cmdf "_.move"   s "" "_non" (txtins (entget e)) "\\")
  15.             (vl-cmdf "_.rotate" s "" "_non" (txtins (entget e)))
  16.             (while (= 1 (logand 1 (getvar 'cmdactive))) (vl-cmdf "\\"))
  17.         )
  18.     )
  19.     (princ)
  20. )
  21. (defun txtins ( e )
  22.     (trans
  23.         (cdr (assoc (if (= 0 (cdr (assoc 72 e)) (cdr (assoc 73 e))) 10 11) e))
  24.         (cdr (assoc 210 e)) 1
  25.     )
  26. )

Commands are RT (Rotate-Text) & MRT (Move-Rotate-Text)
« Last Edit: July 27, 2015, 04:48:12 PM by Lee Mac »

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Quick rotate and / or move-rotate
« Reply #3 on: July 27, 2015, 04:43:18 PM »
argh, help please?

how come
Code: [Select]
(cdr (assoc 10 (entget s))) doesn't work?

Code - Auto/Visual Lisp: [Select]
  1. (entget (car s))
« Last Edit: July 28, 2015, 03:55:07 AM by Lee Mac »

chauhuh

  • Guest
Re: Quick rotate and / or move-rotate
« Reply #4 on: July 27, 2015, 07:48:51 PM »
Thanks Lee. I guess I just don't get it. Changing my code with that in it still makes me select the text again. Suppose I'll have to pick through your code and learn some new tricks.

Thanks.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Quick rotate and / or move-rotate
« Reply #5 on: July 27, 2015, 09:45:01 PM »
You need an a CR after you offer up to entity to the rotate command.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

WillCAD

  • Guest
Re: Quick rotate and / or move-rotate
« Reply #6 on: August 11, 2015, 09:22:20 AM »
argh, help please?

how come
Code: [Select]
(cdr (assoc 10 (entget s))) doesn't work?

Code: [Select]
(defun c:rotatetextfrominsert (/ s en e)
  (if (and (setq s (entsel "\nSelect any TEXT or MTEXT: "))
   (wcmatch (setq en (cdr (assoc 0 (setq e (entget (car s))))))
    "*TEXT"
   )
      )
    (progn
      (command "rotate" s (cdr (assoc 10 (entget s))) pause)
    )
    (prompt "\nObject is not a TEXT or MTEXT.")
  )
  (princ)
)

Thanks.

Code: [Select]
(setq s (entsel "\nSelect any TEXT or MTEXT: "))
This line uses entsel to select your text entity. But entsel doesn't just return the name of the selected entity; it returns a 2-item list (s) containing the entity name, and the coordinates of where it was selected.

Code: [Select]
(cdr (assoc 10 (entget s)))
In this, you're trying to feed entget the whole 2-item list (s) that you got from the entsel. entget chokes when you try to feed it a list. That's why it doesn't work; you have to feed entget just the entity name.

So, by adding an extra car to the sequence, you specify that you only want to feed it the first element of list (s), which is the entity name.

Code: [Select]
(cdr (assoc 10 (entget (car s))))
You have the extra car in line 3, where you're checking to see if the selected entity is text or mtext. You just left it out of line 8. Don't forget to add the extra right parentheses when you put it in there!

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Quick rotate and / or move-rotate
« Reply #7 on: August 11, 2015, 09:38:30 AM »
There's this

Code - Auto/Visual Lisp: [Select]
  1. (defun mr ( / ent txt svosmode)
  2.   (defun *error* ( msg )
  3.     (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
  4.         (princ (strcat "\n** Error: " msg " **"))
  5.         )
  6.     (setvar 'osmode svosmode)
  7.     (setvar 'cmdecho 1)
  8.     (princ)
  9.     );defun
  10.   (setvar 'cmdecho 0)
  11.   (setq svosmode (getvar 'osmode)
  12.         txt "\nSelect Base point for Move/Rotate:"
  13.          )
  14.   (while (and (not (setq ent (entsel txt))))
  15.     (setq txt "\nNothing Selected, Please try again !")
  16.     )
  17.   (if (osnap (cadr ent) "END")
  18.     (progn
  19.       (princ "\nSelect Displacement Point: ")
  20.       (vl-cmdf "_.move" (car ent) "" (cadr ent) pause)
  21.       (setvar 'osmode 0)
  22.       (princ "\nSelect Rotation Angle: ")
  23.       (vl-cmdf "_.rotate" (car ent) ""  (getvar 'lastpoint) pause)
  24.       (setvar 'osmode svosmode)
  25.       (setvar 'cmdecho 1)
  26.       (princ)
  27.       )
  28.     )
  29.   );defun (mr)
  30. (vlax-add-cmd "mr" 'mr "Move/Rotate")
  31.  

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Quick rotate and / or move-rotate
« Reply #8 on: August 11, 2015, 11:44:05 AM »
@ snownut2: I think you have forgotten something. (car ent) will most likely not be an 'exact' point.

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Quick rotate and / or move-rotate
« Reply #9 on: August 11, 2015, 12:02:21 PM »
@ snownut2: I think you have forgotten something. (car ent) will most likely not be an 'exact' point.

typo : (car ent) = 'ename ; (cadr ent) = 'list
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Quick rotate and / or move-rotate
« Reply #10 on: August 11, 2015, 01:34:00 PM »
@ snownut2: I think you have forgotten something. (car ent) will most likely not be an 'exact' point.

typo : (car ent) = 'ename ; (cadr ent) = 'list
You are right Ribarm and I have misread Snownut2's code.
The code will work (provided that the osnap "END" (which need not be active) is found.
The trick is that (setvar 'osmode 0) is performed after the first (vl-cmdf) call.

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Quick rotate and / or move-rotate
« Reply #11 on: August 11, 2015, 05:53:40 PM »
@ snownut2: I think you have forgotten something. (car ent) will most likely not be an 'exact' point.

typo : (car ent) = 'ename ; (cadr ent) = 'list
You are right Ribarm and I have misread Snownut2's code.
The code will work (provided that the osnap "END" (which need not be active) is found.
The trick is that (setvar 'osmode 0) is performed after the first (vl-cmdf) call.

roy-043
It works slick as a bean......for move /  rotating a single entity, whether it be text, block, line or whatever...with minimal user input.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Quick rotate and / or move-rotate
« Reply #12 on: August 12, 2015, 03:32:51 AM »
It works slick as a bean......for move /  rotating a single entity, whether it be text, block, line or whatever...with minimal user input.
Since you check for osnap "END" I don't think the code will work for text entities, or if a block is selected by clicking a nested circle. And of course there has to be a running osnap to begin with.