Over The Border (vbord.lsp)One of the problems with using Paperspace is the inability to see the extents of the viewport when Tilemode is 1. Working in Modelspace when Tilemode is 0 will show you the viewport but is very cumbersome. What is needed is a border in Modelspace which matches the viewport, thus defining the area in which you can work. VBORD.LSP does just that; determining the dimensions of your the current viewport and drawing a border to those dimensions in the Defpoints layer so it won’t plot.The ListingThe program description is fairly long since it contains instructions on how to modify the program to allow for the difference in the monitor dot pitch values between horizontal and vertical.After this, the program is given its name, VBORD, and the variables it uses are localized. This is followed by setting a variable called PIX_RATIO to 1.0. This is a default value and will need to be changed once the program has been installed. Lumped into this SETQ are the saving of some Setvar values for restoration at the end of the program Command echoing is then turned off to prevent printing the command sequences to the command line during program operation. The following line uses a command sequence to set the UCS parallel to the view. This is needed to get values in Modelspace that are lined up with the viewport. Another SETQ function is then started, this one setting all the other variables with values. The first five variables are used to store values from various Setvars. Starting with X_CEN, this is the X value of the Viewctr Setvar, extracted using the CAR function. Y_CEN is the Y value of Viewctr, extracted with the CADR function. Viewctr is the Setvar that contains the co-ordinates of the centre of the current viewport. Since many people are confused by CAR, CDR etc, I will endevour to explain it a little. CAR returns the first element of the nominated list; CDR returns a list containing all but the first element of the nominated list. CADR is a concatenation of CAR and CDR, getting the first element of a list containing all but the first element of the original list. This effectively gets the second element of the original list which, being a list defining a point, is the Y value of the point. SCRGHT is then set to the value in the Viewsize Setvar which is the height of the the current viewport in drawing units. X_DIM and Y_DIM are then set to the width and height of the current viewport in pixels, extracted from the Screensize Setvar using CAR and CADR as before. Since we need the width of the viewport in drawing units so as to draw the border, variable XY_RATIO is set the X:Y ratio of the viewport by dividing X_DIM by Y_DIM. We then multiply the height of the viewport (SCRHGT measured in dwg units) by XY_RATIO and the pixel ratio (PIX_RATIO) to obtain the width of the viewport in drawing units. We then set variable LEFTEX to the X value for the left extents of the viewport by subtracting half of the screenwidth from the X (variable X_CEN) value of the viewport centre. Similarly, the right hand extents is calculated by adding half the screen width the the X value of the centre of the viewport. Variables BOTEX and TOPEX are set to the bottom and top extents of the viewport by subtracting and adding half the height of the viewport from the viewport centre. The four corner points of the border are then built up by creating a list of the numbers in the last four variables. PT2 will be the bottom left-hand corner of the viewport, being created by listing the LEFTEX and BOTEX values plus a Z coordinate of zero. Likewise PT3 will be the bottom right-hand corner, PT4 will be the top right-hand corner and PT5 will be the top left-hand corner. This ends the SETQ. Now for the work. A COMMAND function user uses the LAYER command to make DEFPOINTS the current layer. The Make option is used so that if it doesn’t exist, it will be created. A second COMMAND function then uses the PLINE command to draw a polyline of zero width around the viewport, using the four corner points previously created. With the border complete, a third COMMAND function then restores the UCS to its previous state. The CMDECHO, CLAYER and PLINEWID Setvars are then restored to their original values and the program the exits, the PRINC function on the second-to-last line preventing the value of the PLINEWID Setvar being printed to screen. |
©1996-2001 ZOTO Technologies