After doing a dview>twist to rotate a view in a viewport (to an arbitary angle), I want to be able to rotate the ucs back by the same value as the twist (so I can save a UCS that appears orthagonal for that particular viewport).
Checking the value of the viewtwist variable from the command line via the 'setvar' command gives the value I'm looking for, but if you try and abstract the value - via (getvar "viewtwist") the result you get is a different value. Its actually the value reported in the view>details dialogue box.
If anyone can understand my ramblings and can offer an explanation I'd be grateful.
Thanks
AutoCad never ceases to surprise me, I've been using it as a 2d drafter for the best part of 15 years and you can still miss some of the most basic (but not so obvious) facilities. I should have learnt by now that the prompts on the command line and the documented help don't always tell you the whole story.
Thanks for your help.
Richard
;;;TWIST.lsp takes out the guess work of rotating the current viewport display.
;;;When using the command DVIEW, TWist, you either HAVE to know the exact angle to rotate the display to,
;;;or, you have to eyeball what the angle will be.
;;;This routine takes away ALL the guess work by allowing you to pick two points along an object
;;;which will make that angle horizontal to the current viewport display
;;;written and copyright by Murray Clack
;;;September 5, 2002
;;;Modified August 28, 2003
(defun c:TWIST (/ AB SA OM AUP AU AN ANG ANG2) ;;;define command and variables
(setvar "cmdecho" 0) ;;;turns off command echo
(setvar "ucsfollow" 0) ;;;turns off ucsfollow
(setq AB (getvar "angbase")) ;;;saves current angbase
(setvar "angbase" 0) ;;;sets angbase to 0
(setq SA (getvar "snapang")) ;;;saves current snapang
(setvar "snapang" 0) ;;;sets snapang to 0
(setq OM (getvar "orthomode")) ;;;saves current orthomode
(setvar "orthomode" 0) ;;;turns orthomode off
(setq AUP (getvar "auprec")) ;;;saves the angle units precision
(setvar "auprec" 8) ;;;sets the angle unit precision to a higher value
(setq AU (getvar "aunits")) ;;;saves the angle units
(setvar "aunits" 0) ;;;sets the angle units to decimal
(command ".ucs" "") ;;;set the UCS to world
(setq AN (getangle "\nPick angle of alignment to make HORIZONTAL to current viewport display: ")) ;;;saves Radian angle
(setq ANG (cvunit AN "radian" "degree")) ;;;converts radian angle to decimal angle
(setq ANG2 (- 360.0 ANG)) ;;;determines angle to be set to world
(command ".dview" "" "tw" ANG2 "") ;;;twists the viewport display to new angle
(setvar "aunits" AU) ;;;resets the previous angle units
(setvar "angbase" AB) ;;;resets the previous angbase
(setvar "auprec" AUP) ;;;resets the previous angle unit precision
(setvar "orthomode" OM) ;;;resets orthomode
(setvar "snapang" SA) ;;;resets snapang
(command ".ucs" "V") ;;;sets the UCS to the current view
(princ) ;;;exit command quietly
) ;;;that's all folks
thanks for that. normally I would do something very similar via standard commands i.e UCS>3point and give two precise points which would lie on the proposed x-axis, typing PLAN>return>return would then align the view correctly in the viewport and you could save the current UCS against a name so you could toggle between WCS and UCS as you pleased. But.....
some users I work with don't want to align points horzontally in the viewport, as you said, they may want to eyeball the view on a purely arbitary basis (maybe to fit a view in diagonally within a viewport). In this situation DVIEW is always easier for them, but it was a matter of restoring a ucs to appear horizontal in that view. As was pointed out to me, UCS>V does just that without any complications.
Thanks to all for your responses.
No, not just for paperspace.
A more accurate definition is in HELP:
"Stores the view twist angle for the current viewport."
I now realise that the difference in values of twist reported by cad was none other than ones in degrees the others in radians.