Author Topic: Align North  (Read 243 times)

0 Members and 1 Guest are viewing this topic.


  • Newt
  • Posts: 80
Align North
« on: July 28, 2022, 09:57:35 AM »
Help to fix this route!
Code - Auto/Visual Lisp: [Select]
  1. (defun c:autorotatenorth (/ ss ent1 tw new rt temp blo ent2 elist)
  2. (setvar 'ctab tab)
  3.       (setq ss (ssget "_x" '((0 . "VIEWPORT") (100 . "AcDbViewport") (8 . "-TEXT"))))
  4.       (setq ent1 (ssname ss 0))
  5.       (setq tw (entget ent1))
  6.       (setq new (cdr (assoc 0 tw )))
  7. (cond ((= new "VIEWPORT") (setq rt (cdr (assoc 51 tw))))
  8.       ((= new "LWPOLYLINE") (setq temp (entget (cdr (assoc 330 tw)))) (setq rt (cdr (assoc 51 temp)))))
  9.       (setq blo (ssget "_x" '((2 . "NORTH") (8 . "Symbol"))))
  10.       (setq ent2 (ssname blo 0))
  11.       (setq elist (entget ent2))
  12.       (setq elist (subst (cons 50 rt) (assoc 50 elist) elist))
  13.   (entmod elist)) (princ))

It will work through Layouts to match viewports
  • Each layout have only single no of viewport with layer name "-TEXT"
  • Each layout have only single no of North block name "NORTH" with layer name "Symbol"
"Save Energy"


  • Needs a day job
  • Posts: 7437
Re: Align North
« Reply #1 on: July 28, 2022, 05:19:44 PM »

Windows 11 x64 - AutoCAD /C3D 2022

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12696
  • London, England
Re: Align North
« Reply #2 on: July 28, 2022, 06:04:30 PM »
Time flies :-(


  • Swamp Rat
  • Posts: 1037
  • 40 + years of using Autocad
Re: Align North
« Reply #3 on: July 28, 2022, 11:44:49 PM »
Not as long, my attempt only 2 years old. Just rotates any object so no need for block name.

Code: [Select]
; Rotate a block in pspace to match world in model
; By Alan H Aug 2020

(defun c:roblklay ( / obj1 obj rot ent)
(command "._PSPACE")
(setvar 'nomutt 1)
(princ "\nSelect a viewport")
(setq sss (ssget "_+.:E:S" (list (cons 0 "Viewport"))))
(setq obj1 (vlax-ename->vla-object (ssname sss 0)))
(setq ang (vlax-get obj1 'TwistAngle))

(while (setq ent (entsel "Pick block Enter to exit"))
(setq obj (vlax-ename->vla-object (car ent)))
(vla-put-rotation obj ang)


A man who never made a mistake never made anything


  • Bull Frog
  • Posts: 270
  • ByLayer=>Not0
Re: Align North
« Reply #4 on: July 29, 2022, 09:19:09 AM »
For those using AutoCAD Map 3D & verticals only the undocumented "-MAPINSERTPLE" command will add North Arrows in Paper Space matching Model Space Rotation by selecting a Viewport Boundary. If you twist the viewport afterwards the North Arrow automatically rotates to match.
Described here:
and here:;all
For the record, here are the 3 "types":

2 = North Arrow
3 = Scale Bar
4 = Legend

(The "Select a viewport for the <type>:" command prompt changes based on which number you use.)

 The Symbols folder for the "Map - North Arrows.dwg" can be opened with the Macro:
Code: [Select]
^C^C^P(progn(startapp "explorer" (strcat "/n,/e," (vl-string-subst (strcat "Map" (chr 92) "Sample" (chr 92) "Symbols") "express" (vl-filename-directory (findfile "acetauto.lsp")))))(princ));
I modified all of them to use masked Mtext with Standard text style referencing TrueType fonts so they wouldn't require adding additional text styles and displayed better over images into "Blocks.dwg" attached. Added a drop-down with macros of the North Arrows I've used like this one:
Command Name: Aerial N↑
Macro:                ^C^C(command "-MAPINSERTPLE" "G://ENGDESGN//BeaufordT//Blocks//Blocks.dwg,Aerial,2")
Notice macro includes drawing name with path,block name,type=2.
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D