AutoLISP: Rotate Multiple Objects Around Their Base Point

There are 2 things in this blog post that I want to point out.

1) Share a LISP routine that rotates multiple objects around their individual base points…

2) The lisp routine shown in this post hasn’t been altered since 1991 and it still works in AutoCAD 2014. This may not seem like a big deal but with all of the various programming languages available to be used within AutoCAD, the power of using a LISP routine that hasn’t had to be changed or updated in over 20 years is pretty impressive.

Rotate Multiple Lisp routine with date shown

Rotate Multiple Lisp routine with date shown

The Routine allows you to rotate multiple objects such as blocks and text objects that have an “Insertion Point”  to a user-specified angle. And instead o0f rotating everything around one base point, the object’s individual base point is used.

In the example below, there is a vertical column of blocks that are rotated clockwise by 90s. I don’t know why, but all that I know is that I want them right-side-up.

Rotate Multiple

Here’s how:

  • Load the routine
  • ROTMULT <enter> to start
  • Select objects
  • <enter> when finished selecting
  • “Enter Rotation Angle:” enter a positive number to rotate the objects counter-clockwise (example 90) and a negative number to rotate the objects clockwise (example -90)

~Enjoy



;* Rotate Multiple
;* Rotates many entities around their respective basepoints
;* allows selection by AUTOCAD selection sets or SSX.
;* Written by David Husch, January 1991

(defun c:rotmult ()
  (prompt "Select Entities to Rotate, <ENTER> for SSX.")
  (setq ss (ssget))
  (if (not ss) (setq ss (ssx)))
  (setq num (sslength ss))
  (setq x 0)
  (if ss 
  	(if (setq ang (getreal "Enter Rotation Angle: "))
	  	(repeat num
		  	(setq ename (ssname ss x))
		    (setq elist (entget ename))
			(setq pnt (cdr(assoc 10 elist)))
			(command "Rotate" ename "" pnt ang)
 		    (setq x (1+ x))
	    	)
	  	)
    )
  )

Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, AutoLISP: Blocks, AutoLISP: Modify, AutoLISP: Text. Bookmark the permalink.

29 Responses to AutoLISP: Rotate Multiple Objects Around Their Base Point

  1. Jordan says:

    This is pretty great, thanks. Adding it to my utilities.lsp file now.

  2. Lucio says:

    It works very good, very good for Electrical Plans, Thank you very much

  3. mary says:

    How do you load the routine??

  4. Jon Thompson says:

    i tried using it today. not sure if you have to be an administrator for it to work. i cannot get it to. seems like the code is different in the video than in body of this article as well.

    • AutoCAD Tips says:

      Jon – I tried this routine with both ACAD 2014 & 2015 and they both work fine. I am wondering if you have your SECURELOAD variable turned on. Once you load the LISP routine does it prompt you and ask what you want to do? If so, type in SECURELOAD [enter] at the command line and then set it to 0 (zero)
      after that is set you shouldn’t be prompted after loading lisp routines.
      ~Greg

  5. angelo zulueta says:

    Hi! I have a problem. :( All of my text are facing the wrong way. Is there any other way or shortcut to rotate them all at once?

    • AutoCAD Tips says:

      Yes – It sounds like your system Variable MIRRTXT was set to 1. When it is set to 1 and then go to mirror objects and possibly text objects (single line text, Mtext or even attributes, The objects will be mirrored and as you are experiencing, the text will display backwards and end up haying to read the text as a reflection in a mirror.
      So if you can erase the content that was mirrored then use the command MIRRTEXT in the command line, please set it to 0 [zero]. Then mirror the objects again, they should be readable as expected.

      I hope this helps. If not maybe I can find a routine that will flip the text objects back to normal
      ~Greg

  6. Khanh says:

    Hi. Could you please explain to me what the following statements mean?

    (prompt “Select Entities to Rotate, for SSX.”)
    (setq ss (ssx)

  7. Khanh says:

    And what definition data of the object does (assoc 10 elist) statement retrieve?

    • Michael Tsai says:

      (assoc 10 elist) takes the start point (10 29.4036 28.6588 0.0), if you want the end point just change 10 to 11.

      ELIST = ((-1 . ) (0 . “LINE”) (330 . ) (5 . “18E”) (100 . “AcDbEntity”) (67 . 0) (410 . “Model”) (8 . “0”) (100 . “AcDbLine”) (10 29.4036 28.6588 0.0) (11 48.2395 28.6588 0.0) (210 0.0 0.0 1.0))
      _$

  8. Sherif says:

    This is a great lisp , however I was wondering if there is a lisp to set the absolute angle of rotation to a certain angle.

    My issue is that I am trying to set the rotation of many entities to zero without selecting them one by one.

    would you please reply to my email

  9. Hadi says:

    Hats off……….. to you a great job.
    Thanks a lot…………..worked perfectly.

  10. Jayson Lavarias says:

    It works great. just wondering if you could add reference angle option for rotation.

  11. Aygun says:

    Hi, this is great! Is it possible to write such a lisp for ROTATE3D? I need to rotate multiple texts on their own base point, -90 degree on Y axis. I want to see all the texts on the LEFT view instead of the TOP. I would really appreciate if you could help me.

  12. Lwin Min Paing says:

    Like a multiple rotation, is it possible to do for multiple mirror? I am seaching for lisp that could mirror the individual block in one time command.

    • Matt Hardcastle says:

      Bit late I’m sure but see the below, hope it can help others. I too wanted to mirror multiple blocks about their base points so used the lisp posted above as a template. The below mirrors the objects in the Y axis. This is defined within the lisp by the base point and 1 unit above the base point (@0,1). This could be easily changed for X axis mirroring by swapping for @1,0

      I’m sure this could be set up to prompt the user to either enter an angle or define two points but I’ll let someone else figure that out!

      ;* Mirror Multiple
      ;* Mirrors many entities around their respective basepoints
      ;* allows selection by AUTOCAD selection sets or SSX.
      ;* Written by Matthew Hardcastle, May 2016

      (defun c:mirrmult ()
      (prompt “Select Entities to Mirror, for SSX.”)
      (setq ss (ssget))
      (if (not ss) (setq ss (ssx)))
      (setq num (sslength ss))
      (setq x 0)
      (if ss
      (repeat num
      (setq ename (ssname ss x))
      (setq elist (entget ename))
      (setq pnt (cdr(assoc 10 elist)))
      (command “Mirror” ename “” pnt “@0,1” “y”)
      (setq x (1+ x))
      )
      )
      )

  13. Florentina says:

    PERFECT! THANKS A LOT!

  14. Nenad Stojanovic says:

    Hello,

    when I draw a rectangle using built-in tool for it this LSP seems to work. However, whenever I use it to rotate regions that I have drawn myself, it prompts me with message “Rotate”, but what ever I do it either leaves objects unchanged or deletes them. What should I do?

    • AutoCAD Tips says:

      I think that what is throwing it off is that there isn’t a base point for a region.
      For regions, you’ll just have to use the rotate command on them.
      ~Greg

  15. Maestrobih says:

    Nice, thanks for sharing with the rest of us.

  16. chamse says:

    hi
    autocad show me a message Rotate Commande inconnue “ROTATE”. Appuyez sur F1 pour obtenir de l’aide.
    Commande:

  17. Mikee says:

    it doesn’t seem to work on groups.. in a set of 5 groups I selected, only two rotates, and worst of all, the 2 group-objects rotated like 50times!!!! I’m using Autocad 2014, and it’s my first time using lisps.. can someone help?

  18. Hello,
    It’s a great tool. It saves time.

    I have a suggestion for improvement to make.
    But I think this is for all programmers lisp language.
    This is the maximum use commands in the international format.

    For example, I use a French version of Autocad and routine does not work.
    The “Rotate” is not recognized.
    I changed to “_Rotate” and it works without any worries.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s