Rotate view to match a selected object...

Rotate view to match a selected object...

Jerry_Barnes
Collaborator Collaborator
2,771 Views
15 Replies
Message 1 of 16

Rotate view to match a selected object...

Jerry_Barnes
Collaborator
Collaborator

I'm looking for a way to rotate my model space view to match the angle of a rotated object such that the view rotates to make that object horizontal. The important catch here is I want the zoom factor to remain the same as before the rotation. For example, setting the UCS to some angle and using plan command will do that, but it zooms out to Extents. I wish for the view to rotate but remain so that I am still looking at the same zoomed-in area. 

0 Likes
2,772 Views
15 Replies
Replies (15)
Message 2 of 16

ecfernandez
Mentor
Mentor

Hi @Jerry_Barnes, I think the zoom-in cannot be the same since you are changing the UCS. However, try the ZOOM command, then PREVIOUS, to see if the program takes your view to where you had it before the UCS change.

Regards! 

Camilo Fernández

Civil engineer | Specialist in design, construction, and maintenance of roadways

EESignature

LinkedIn
0 Likes
Message 3 of 16

Joe-Bouza
Mentor
Mentor

Rotate the viewport use the object for reference angle. 

Joe Bouza
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Message 4 of 16

Jerry_Barnes
Collaborator
Collaborator

Which command would I use to rotate the viewport in order to input the angle?

0 Likes
Message 5 of 16

Pointdump
Consultant
Consultant

Hi Jerry,
How about DVIEW >> TWIST?
Dave

Dave Stoll
Las Vegas, Nevada

EESignature

64GB DDR4 2400MHz ECC SoDIMM / 1TB SSD
NVIDIA Quadro P5000 16GB
Windows 10 Pro 64 / Civil 3D 2025
Message 7 of 16

AllenJessup
Mentor
Mentor

I use this Lisp. Please pay attention to the test at the top of the file.

 

AllenJessup_0-1707140210764.png

 

Allen Jessup
CAD Manager - Designer
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Message 8 of 16

BrianHailey
Mentor
Mentor

I'm don't have access to C3D at the moment but perhaps ALIGNSPACE? It may change the scale but if you are using a standard scale for your viewport, it should be trivial to set it back to what it originally was.

Brian J. Hailey, P.E.



GEI Consultants
My Civil 3D Blog

0 Likes
Message 9 of 16

doni49
Mentor
Mentor

Here's a lisp routine that I wrote years ago that comes close to what you're asking for.  You have to select two points that you want to make horizontal.

 

;|
         Author:   Don Ireland

         Purpose:  To allow user a more intuitive method of rotating a view.

         Date:     4/96

         Version:  3.0

         History:  1-23-03 Added the "Default" angle of the current dvtwist setting.
                   12-6-04 Added error checking to see if you are Paperspace/or a locked viewport.
       

|;
(defun rtd (a)
  (setq a(/ (* a 180) pi))
)
(load "vplocks")
(defun c:dvtwist( / vpl? twist)
  (if (mspace?)
    (progn(if (and (/= "Model" (getvar "ctab"))(setq vpl?(vplocked?)))(lockmviews -3))
    (setq twist(rtd(Getangle (strcat "\nEnter New Horizontal Angle <" (rtos (getvar "viewtwist"))">:  "))))
    (if (not twist)(setq twist (getvar "viewtwist")))
    (command "dview" "" "Tw" (- 0 twist) "")
    (setvar "snapang" (- 0 (getvar "viewtwist")))
    (if (and vpl? (/= "Model" (getvar "ctab")))(lockmviews 3)));end progn

    (progn(princ "\nThis command is not available in Paperspace.  Please switch model space.")
    (princ))
  )
)
(defun c:dvt()(c:dvtwist))


Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 10 of 16

Joe-Bouza
Mentor
Mentor

Jeff Mischler showed me this. takes about 5 seconds

 @Jerry_Barnes , @BrianHailey , @AllenJessup , @rgrainer , @doni49 

 

JoeBouza_0-1707249430687.png

 

JoeBouza_1-1707249468966.png

SHIF>>@ PICK END OR NEAR ON LINE 

JoeBouza_2-1707249623168.png

 F8 AND YOUR VIEW IS ROTATED TO THE OBJECT.

The just gip the corners ti the paper

JoeBouza_4-1707249936185.png

 

Joe Bouza
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 11 of 16

doni49
Mentor
Mentor

@Joe-Bouza It looks like you're rotating the view itself.  I've done that in the past two.  But then I end up needing to change the viewport border to fit within my titleblock's drawing area.



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

0 Likes
Message 12 of 16

Joe-Bouza
Mentor
Mentor

@doni49 , correct

 

I have already started the day with Combined shampoo and conditioner, and Velcro sneakers. So, I am ahead of the game saving time (LOL) ... all in good fun

JoeBouza_0-1708005413758.png

 

Joe Bouza
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 13 of 16

tguytonS8TYU
Observer
Observer

Used to have a LISP that you could DV TWIST by using a line. Anyone know of a LISP?

Very nice tool that Carlson utilizes and it uses entities.

Message 14 of 16

doni49
Mentor
Mentor

There's a reply in this thread with my lisp routine included.

 

https://forums.autodesk.com/t5/civil-3d-ideas/sac-saveas-older-format/idi-p/5758574?search-action-id... 

 

Beware that I just realized it uses a lisp routine (VPLOCKS) that I found online a long time ago and don't remember who the author was.  I'll post that here.  My code uses this to check if the current viewport is locked (and can't be rotated).

(defun mspace?( / )
   (or
     (= 1 (getvar "Tilemode"))
     (/= 1 (getvar "cvport"))
     )
   )


(defun vplocked?()
  (and
    (setq *acad* (vlax-get-acad-object))
    (setq *doc* (vla-get-activedocument *acad*))
    (setq vp (vla-get-activePviewport *doc*))
    (= :vlax-true (vla-get-displaylocked vp))
  )
)

 ;;;Lock/unlock paper space viewports
 ;;;  mode = 1 lock all         - (lockmviews 1)
 ;;;  mode = 2 lock selected    - (lockmviews 2)
 ;;;  mode = 3 lock active      - (lockmviews 3)
 ;;;  mode = -1 unlock all      - (lockmviews -1)
 ;;;  mode = -2 unlock selected - (lockmviews -2)
 ;;;  mode = -3 unlock active   - (lockmviews -3)
 (defun lockmviews (
      mode
      /
      cmdecho
      ss ssl ss1
     )
   (setq cmdecho (getvar "cmdecho"))
   (setvar "cmdecho" 0)
   (if (and
  (/= (abs mode) 3)  ;use the active viewport
  (= 0 (getvar "tilemode"))
  (/= 1 (getvar "cvport"))
  )
     (progn
       (setq ss T)
       (c:ss)
     ) ;_ end progn
   ) ;_ end if
   (cond
     ((= 1 (getvar "tilemode"))
      (alert "Switch to paper space and try again.")
     )
     ;;Lock all ------------------------------------------------------------
     ((= mode 1)
      (setq
        ss1 (ssget "X" '(( 0 . "VIEWPORT")))
        ssl (sslength ss1)
        )
      (if (<= 0 ssl)
        (progn
          (command "._mview" "Lock" "On" ss1 "")
   (princ (strcat "\n" (itoa (1- ssl)) " viewport(s) found and locked. "))
   )
        (princ "\nNo viewports found. ")
        )
     )
     ;;Unlock all------------------------------------------------------------
     ((= mode -1)
      (setq
        ss1 (ssget "X" '((0 . "VIEWPORT")))
        ssl (sslength ss1)
        )
      (if (<= 0 ssl)
        (progn
          (command "._mview" "Lock" "Off" ss1 "")
   (princ (strcat "\n" (itoa (1- ssl)) " viewport(s) found and unlocked."))
   )
        (princ "\nNo viewports found. ")
        )
     )
     ;;Lock Selected---------------------------------------------------------
     ((= mode 2)
      (command "._mview" "Lock" "On")
      (setvar "cmdecho" 1)
      (while (and (< 0 (getvar "cmdactive"))
    (wcmatch (getvar "cmdnames") "*mview*")
      ) ;_ end and
        (command pause)
      ) ;_ end while
      (setvar "cmdecho" 0)
     )
     ;;Unlock selected------------------------------------------------------
     ((= mode -2)
      (setvar "cmdecho" 1)
      (command "._mview" "Lock" "Off")
      (while (and (< 0 (getvar "cmdactive"))
    (wcmatch (getvar "cmdnames") "*mview*")
      ) ;_ end and
        (command pause)
      ) ;_ end while
      (setvar "cmdecho" 0)
     )
     ;;Lock active----------------------------------------------------------
     ((= mode 3)
      (lockactivepvp T)
      (princ "\nActive viewport locked. ")
      )
     ;;Unlock active--------------------------------------------------------
     ((= mode -3)
      (lockactivepvp nil)
      (princ "\nActive viewport unlocked. ")
      )
     (T nil)
   )     ;end cond
   (if ss
     (c:ss)
   ) ;_ end if
   (setvar "cmdecho" cmdecho)
   (princ)
 )     ;end lockmviews

 (defun lockactivepvp(   ;get the active paper space viewport
        lock  ;nil = unlock, non-nil = lock
       /
        app doc pvport
       )
   (setq
     app (vlax-get-acad-object)
     doc (vla-get-activedocument app)
     pvport (vla-get-activepviewport doc)
     )
   (if lock
     (vla-put-displaylocked pvport :vlax-true)
     (vla-put-displaylocked pvport :vlax-false)
     )
   (vlax-release-object doc)
   (vlax-release-object app)
   pvport
   )

   



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

0 Likes
Message 15 of 16

Joe-Bouza
Mentor
Mentor

 I rotate the vport plain simple fast

Joe Bouza
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 16 of 16

MMcCall402
Mentor
Mentor

I've been using ALIGNSPACE for years.  I set the rotation first, then the scale.

 

If I'm working with more than a couple sheets I'll make a rectangle in model space at the scale of my drawing sheets and copy it around to get the site coverage I need.  I'll use those rectangles with the Alignspace command and align them to my sheet borders.  Sets the rotation and scale in one shot.

Mark Mccall 
CAD Mangler


EESignature


VHB - Engineering, Inc.