TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mailmaverick on August 28, 2017, 04:09:00 AM

Title: AutoCAD Viewport Rotate Error
Post by: mailmaverick on August 28, 2017, 04:09:00 AM
Please see attached drawing. I have a Viewport in 'Layout' TAB which when I rotate by 90 degrees, it changes its extents.
My VPROTATEASSOC variable is set to 1.


Title: Re: AutoCAD Viewport Rotate Error
Post by: tombu on August 28, 2017, 07:55:33 AM
What commands are you using to rotate it with?  Dview TWist rotates the view, while other methods affect UCS.  What's your UCSFOLLOW set to?
Title: Re: AutoCAD Viewport Rotate Error
Post by: Crank on August 28, 2017, 12:33:31 PM
I see the same.
In Acad2017 it doesn't happen, so I'll guess this is a bug that's new in 2018.1.

But the size of your viewport is only 0.088 x 0.038 drawing units. After rotation the new viewport is 0.1x0.1 drawing units. That's still very very small.
Larger (normal) viewports don't have this problem.
Title: Re: AutoCAD Viewport Rotate Error
Post by: mailmaverick on August 29, 2017, 06:18:36 AM
I am using ROTATE command to rotate it.
Title: Re: AutoCAD Viewport Rotate Error (Bug in AutoCAD)
Post by: mailmaverick on August 31, 2017, 12:46:19 PM
Still no idea why I'm facing this problem
Title: Re: AutoCAD Viewport Rotate Error
Post by: Crank on August 31, 2017, 01:04:39 PM
In Acad2018.1 they have added extra options to viewports.

As a result of this the minimum size of a viewport after rotation appears to be 0.1x0.1 drawing units.
Normally this shouldn't be a problem, because your layout is much larger.
I wonder why this is important for you, because such a tiny viewport will look like a dot on your sheet.
Title: Re: AutoCAD Viewport Rotate Error
Post by: tombu on September 01, 2017, 10:20:20 AM
Only way I could reproduce your issue was to set VPROTATEASSOC to 0.  With VPROTATEASSOC set to 1 (default) ROTATE works fine.
Title: Re: AutoCAD Viewport Rotate Error
Post by: mailmaverick on September 14, 2017, 10:33:34 AM
Another bug which i have found in AutoCAD 2014 is that when I rotate the viewport using (command "ROTATE" .........) automatically a closed polyline with coordinates same as of Viewport gets created which itself binds with the viewport entity. Anybody else came across such problem ?
Title: Re: AutoCAD Viewport Rotate Error
Post by: Crank on September 16, 2017, 03:49:09 AM
That's not a bug, it's how it works:
If you look at the dxf-codes (https://www.autodesk.com/techpubs/autocad/acad2000/dxf/viewport_dxf_06.htm), you'll notice that an angle of the viewport isn't present (a viewport is allways orthogonal, but you can rotate/twist the view).
A rotated viewport is clipped from an object (polyline/circle/elipse/region) and has a twisted view. In this case the polyline is automaticly generated.
Title: Re: AutoCAD Viewport Rotate Error
Post by: mailmaverick on September 18, 2017, 04:29:39 AM
Thanks for your answer Crank. One more thing, if a viewport is rotated, its properties window does not show its rotation. So how to know whether a viewport has been rotated or not ?
Title: Re: AutoCAD Viewport Rotate Error
Post by: ahsattarian on August 11, 2021, 07:07:12 AM
Code - Auto/Visual Lisp: [Select]
  1. (setq s (ssname (ssget ":e:s" '((0 . "viewport"))) 0))
  2. (cdr (assoc 51 (entget s)))
Title: Re: AutoCAD Viewport Rotate Error
Post by: PM on August 17, 2021, 05:06:11 PM
I use this code to rotate viewport. I dont know if it is what are you looking for

Code - Auto/Visual Lisp: [Select]
  1. ; DVA.LSP
  2.  
  3. ; Jim Nakazawa
  4. ; (415) 768-1234
  5.  
  6. ; TO SET DVIEW TWIST ANGLE BY POINTING TO AN EXISTING LINE
  7. ; FIRST DRAW THE LINE FROM LEFT TO RIGHT THAT YOU WANT TO SET THE DVIEW
  8. ; TWIST ANGLE FROM
  9.  
  10. (defun C:DVA (/ rgm a b pt1 pt2 ang1 )
  11.   (setq rgm (getvar "regenmode"))
  12.   (command "setvar" "regenmode" 0)
  13.   (setq a (entsel "select a line to DVIEW TWist angle: "))
  14.   (setq b (entget (car a)))
  15.   (setq pt1 (cdr (assoc 10 b)))
  16.   (setq pt2 (cdr (assoc 11 b)))
  17.   (setq ang1 (angle pt1 pt2))
  18.   (setq ang1 (/ (* ang1 200.0) pi))
  19.   (setq ang1 (- ang1))
  20.   (command "dview"  "" "tw" ang1 "")
  21.   (command "setvar" "regenmode" rgm)
  22.   (princ "Dview Twist Angle Set to ") (princ (+ 400.0 ang1)) (terpri)
  23. ;this should be modified to show angle in current angular units
  24.   (princ)
  25. ) ;this routine seems to work
  26.