DVIEW Twist + Snapang wrong direction

DVIEW Twist + Snapang wrong direction

EBDBC3D
Advocate Advocate
1,291 Views
5 Replies
Message 1 of 6

DVIEW Twist + Snapang wrong direction

EBDBC3D
Advocate
Advocate

This LISP routine sets a Dview Twist angle and Snapang. If you type the Dview Twist angle in, it uses the negative of that, but selecting 2 points works correctly. Is there a way to resolve that? Is there a way to also force it to 2 decimal places for the twist angle and snapang and ignore the drawing rotation unit precision? Thanks.

 

(defun c:DVTW (/ cmde twa sna)
(princ "Pick direction points or enter angle:")
(setq twa (getangle))
(setq sna twa)
(setq twa (angtos twa (getvar "aunits")))
(setq twa (strcat "-" twa))
(command "dview" "" "tw" twa "")
(setvar "snapang" sna)
(command "zoom" "e")
(princ)
)

0 Likes
1,292 Views
5 Replies
Replies (5)
Message 2 of 6

ronjonp
Mentor
Mentor

Are you trying to 'square up' the crosshairs with the screen? If so, set your dview twist then set UCS to View.

 

(defun c:dvtw (/ twa)
  (if (setq twa (getangle "\nPick direction points or enter angle:"))
    (progn (setvar 'cmdecho 0)
	   ;; Two decimal places for TWA
	   (setq twa (rtos (* 180.0 (/ twa pi)) 2 2))
	   (command "_.Dview" "" "Twist" twa "")
	   (command "_.UCS" "_View")
	   (command "_.zoom" "E")
	   ;; (setvar 'snapang twa)
	   (setvar 'cmdecho 1)
    )
  )
  (princ)
)

 

 

 

0 Likes
Message 3 of 6

EBDBC3D
Advocate
Advocate

Thanks, but I don't want to change the UCS, that would get me fired lol, just the crosshairs/snapang variable. The code you provided worked for setting the DView/Twist angle when the angle is typed in, but not selecting 2 points. 

0 Likes
Message 4 of 6

ronjonp
Mentor
Mentor

Have you seen this? The function even has the same name.

Message 5 of 6

TomBeauford
Advisor
Advisor

The reason VIEWTWIST (System Variable) is in the reversed direction is because ANGDIR (System Variable) is set to the default of 0.

If you set ANGDIR (System Variable) to 1 the lisp should work but make sure it's reset to 0 at the end and in an *error* function so it doesn't cause issues with everything else.

Like ronjonp said this has been done before, but I know how satisfying it is writing your own version. 60% of the code I use was written by ronjonp and other gurus like him since finding & downloading code is quicker than writing it.

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
0 Likes
Message 6 of 6

john.uhden
Mentor
Mentor

What you could probably use is my VTWIST routine that allows you to pick most anything that has an angle, and it sets the snapang as well.  I am not an architect.  They rotate the world.  I am a civil, and we rotate the camera.

John F. Uhden

0 Likes