Code Red > AutoLISP (Vanilla / Visual)
Detecting orthagonal viewports
mr_nick:
Can anyone give me a pointer as to the best way to accurately detect any viewports on a drawing sheet that are displaying orthagonal views? DXF 79 is supposed to indicate this but I have found the results to be very flakey. Creating a brand new VP, it displays as TOP but if I get the DXF 79 value it shows up as 0 meaning it is non-orthagonal. I have to manually change the VP to TOP before it reports the proper DXF 79 value. Also, if I have a VP which is set to TOP but has had a DVIEW twist applied then the value reverts to 0 meaning non-ortho.
Is there a combination of DXF codes that I should search for or is there a more reliable method altogether?
Thanks in advance.
Lee Mac:
How about checking the direction vector of the Viewport, (Direction Property / DXF 16), e.g.
--- Code - Auto/Visual Lisp: ---(defun orthovport-p ( ent ) ( (lambda ( v ) (or (equal '(0.0 0.0 0.0) (v^v v '(1.0 0.0 0.0)) 1e-14) (equal '(0.0 0.0 0.0) (v^v v '(0.0 1.0 0.0)) 1e-14) (equal '(0.0 0.0 0.0) (v^v v '(0.0 0.0 1.0)) 1e-14) ) ) (cdr (assoc 16 (entget ent))) )) ;; Vector Cross Product - Lee Mac;; Args: u,v - vectors in R^3 (defun v^v ( u v ) (list (- (* (cadr u) (caddr v)) (* (cadr v) (caddr u))) (- (* (car v) (caddr u)) (* (car u) (caddr v))) (- (* (car u) (cadr v)) (* (car v) (cadr u))) ))
mr_nick:
Hmm. DXF 16 had actually been my first approach but I dismissed it when something didn't quite work the way it was supposed to - but I can't for the life of me recall what it was. I have tried your code on a number of drawings I'd previously used my original code on and it's working like a charm so I'm guessing that I had made a schoolboy error - I have to admit my code was far less well thought out.
Thanks for code Lee, much appreciated.
Lee Mac:
You're very welcome mr_nick, happy to be of assistance :-)
mr_nick:
I've just rediscovered what the problem was with this approach. If I have a view set up that is showing a section taken at an angle through a building, while the view is not orthagonal because it is not truly squared, it is most definitely not an isometric view as the section is taken through the same Z-plane so not looking up/down at an angle. So I guess my question should have been more along the lines of how do I determine if a VP is displaying a 'true' isometric view?
Navigation
[0] Message Index
[#] Next page
Go to full version