I am trying to find the coordinates of the 4 corners of a viewport in term of WCS in MSPACE, and the viewport is at an angle -- meaning that the view is not Top/Left/Right/Front/Back.
I need to find the coordinates of the 4 corners because I need to feed them to the (ssget "_WP" (list xyLL xyUR xyUR xyLR)) command to select all the entities shown on the viewport.
Currently I am using the following code to find the coordinates of the 4 corners. Unfortunately it only works if the viewport is viewing at Top/Left/Right/Front/Back:
(setq lisScrSize (getvar "screensize")) (setq cxScrWidth (car lisScrSize)) (setq cyScrHeight (cadr lisScrSize)) (setq cyVpHeight (getvar "viewsize")) (setq cxVpWidth (* cyVpHeight (/ cxScrWidth cyScrHeight)) ) (setq cxVpHalfWidth (/ cxVpWidth 2)) (setq cyVpHalfHeight (/ cyVpHeight 2)) (setq lisVpCenter (getvar "viewctr")) (setq xVpCenter (car lisVpCenter)) (setq yVpCenter (cadr lisVpCenter)) ;The coordinates of the 4 corners are: (setq xyVpLwLfWCS (list (- xVpCenter cxVpHalfWidth) (- yVpCenter cyVpHalfHeight)) ) (setq xyVpUpRgWCS (list (+ xVpCenter cxVpHalfWidth) (+ yVpCenter cyVpHalfHeight)) ) (setq xyVpUpLfWCS (list (- xVpCenter cxVpHalfWidth) (+ yVpCenter cyVpHalfHeight)) ) (setq xyVpLwRgWCS (list (+ xVpCenter cxVpHalfWidth) (- yVpCenter cyVpHalfHeight)) )
I am wondering if there is a way to get the coordinates even when the viewport is viewing at an angle.
Please help. Thanks.
Jay Chan
Jimmy Bergmark has a routine to create a polyline in modelspace that has the outline of a viewport.
http://www.jtbworld.com/lisp/vp-outline.htm
It supports twisted views like you're looking for.
Unfortunately the vp-outline program has the same problem. It cannot handle the viewport that is viewing the object at an angle. Attached please find a drawing file. Two of the layouts are viewing a column of ductwork at something like a South-East angle (they are layout "RISER1" and "RISER2"). When you go into the MSPACE of the viewport in RISER1 (there is only one viewport), and move the mouse hovering over the lower left corner of the viewport, you will see that the coordinates are ridiculously large numbers:
But the coordinates that vp-outline comes up with are different. They are:
(-78.8401 113.0044) (156.5796 363.4939) (156.9582 363.1381) (-78.4615 112.6486)
Seem like if the viewport is at a "normal" angle like Top, Left, Right, Front, or Back, the coordinates of the 4 corners of the viewport look very normal. But as soon as the viewing angle is not any one of those "normal" viewing angles, the coordinates of the 4 corners become ridiculously large.
Regardless how ridiculously the coordinates look, when I feed them to (ssget "_WP" (list xyLL xyUL xyUR xyLR)) command, the command can correctly select the objects in the viewport. Therefore, I will have to use those coordinates, and I need to figure out how to calculate them.
Do you know why the coordinates of the viewport can become ridiculously large numbers? How do we find those coordinates using LISP? Thanks in advance for any help that you can offer.
As a side note, seem like vp-outline can only handle plan-view -- the plan-view can be rotated at any angle as long as the object is facing up. Otherwise, the program can only draw one straight line instead of a rectangular outline. For example, if I view the object in Front-View, the program will draw a straight line across the top half of the viewport. Seem like I cannot use this routine.
Jay Chan
The vp-outline routine does work well with dview twisted views, but you want an outline of a 3D rotated view which can be viewed on the model tab in 2D? Not sure if that's posible.
Actually I don't want to add an outline onto my viewport in paper space or model space. I want to select objects inside the MSPACE of a viewport. I am just trying to see if vp-outline can correctly draw an outline on a viewport that is viewing objects in 3D rotated view (such as South-East view). If it could correctly draw an outline, this means it knew how to calculate the coordinates in 3D rotated view. Unfortunately for me, seem like it cannot calculate the coordinates of a viewport that is in 3D rotated view.
I will need to keep looking. I am sure the solution is available somewhere (otherwise, AutoCAD would not be able to display the coordinates in the left corner of the status bar). If you come across anything, please let me know, and I will greatly appreciate that. Thanks in advance.
Jay Chan