[Search tip detail and code files using keywords, tip number, author name, etc ]
Rotate Block to Match Viewport
Tip# 3169 By Mike Roberts On 22-Mar-2009
Rated By 5 users
Categories : Viewports
Software type : AutoCAD 2009
Rename File To : No Files to download.
This LISP routine will rotate a north arrow block to match the rotation of a viewport.

Mike Roberts sends us a LISP routine that will rotate a north arrow block to match the rotation of a viewport in AutoCAD. “After creating countless sheets with north arrows and viewports at random rotations, this tip was born out of necessity. This routine, as simple as it is, is one I find most handy.”

Run the command. It will ask you to select a viewport after which it asks you to select a north arrow. The routine rotates the north arrow to the rotation of the selected viewport. You only need to create a block out of your favorite north arrow with zero rotation.

(defun c:rn()
  (setq tw(entget(car(entsel" Select a Viewport:"))))
  (setq new (cdr (assoc 0 tw)))
                ((= new "VIEWPORT")(setq rt(cdr(assoc 51 tw))))
((= new "LWPOLYLINE")(setq temp (entget(cdr (assoc 330 tw))))(setq rt(cdr(assoc 51 temp))))
  (setq en(car(entsel" Select North Arrow: ")))
  (setq elist(entget en))
  (setq elist(subst (cons 50 rt)(assoc 50 elist) elist))
  (entmod elist)

Notes from Cadalyst Tip Patrol: Great routine and simple to use. This will rotate any block to match the rotation of a viewport, not just a north arrow block.


Average Rating:

User comments
Comment by Hoogenberg,Ingeborg
Posted on 2009-03-24 04:01:39
Neat!!! I immediately stuck it in my menu, thanks!
Comment by Byrd,Amy Meredith
Posted on 2009-03-24 09:18:41
This is a great lisp routine that will save me several steps when setting up rotated sheets. Thanks!