Saturday, August 23, 2014

Graphical Screen Functions


These functions can be used to make changes to the graphical screen. The graphical screen is the drawing area of AutoCAD.


(grclear)


This function is used to clean th active view port of the drawing area. The information is not erased, but made invisible.


If the REDRAW command is used, then the information is visible again.


(grdraw <p1> <p2> <color> [<highlight>])


This function is used to draw a line between the points p1 and p2. The points can be 2D points and 3D points.


The color argument sets the color of the line. If the color argument is -1, then the line is drawn in the color in a complimentary color.


If another vector is drawn over the same points with the color, then the complete line is made invisible.


If the highlight argument is present and unequal to zero, then the line is drawn in a highlighted format.


(grtext [<box> <text> [<higlight>])


With this function you can write text to the screen menu of AutoCAD. I'm afraid screen menus are no longer used. So forget it.


(grread [<track>])


With this function you can read input from devices such as keyboard, digitizer, mouse, etc. But most of the time GET functions are used.


If a mouse is used, then this is what could be given back by the GRREAD fucntion:


(3 (-13.9732 13.0249 0.000000))


The first element is the the code of the device. These are the codes that are available:


2 Keyboard and the ASCII code of the character.


3 Mouse. The point is put in a list.


4 Screen menu cell with the number of the cell.


5 A list of the point for the drag mode. Only if the TRACK argument is unequal to nil.


6 Button number of the mouse.


7 Selected item in TABLET 1 menu.


8 Selected item in TABLET 2 menu.


9 Selected item in TABLET 3 menu.


10 Selected item in TABLET 4 menu.


11 Selected item in AUX 1 menu.


12 Point of the mouse.


13 Selected screen menu item.


(menucmd <text>)


This is another function that works with the screen menu. We are not using it. So you can forget about it.


Exercise


Now we are going to create an AutoLISP program, that draws circles and lines. The center points of the circles are picked.


To create the AutoLISP program the WHILE function is used. Here is the drawing that is created. Four circles have been drawn. But more circles could be drawn.