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.




Sunday, August 17, 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.




Friday, August 8, 2014

Text Screen Functions

Text Screen Functions


Hari Raya


Sorry. I could not add a new post to my blog for two weeks. It was not my fault. It has to do
with Hari Raya.


I live in Malaysia. And you find a lot of Muslims here. They celebrate Ramadan every year. Ramadan is a month of fasting.


When Ramadan is over, then we have Hari Raya. It lasts a couple of days, when everybody has a national holiday.


But the majority of the people take a holiday. And if they have a shop, they close it. Even Chinese shops and Indian shops are closed.


I do my Internet in an Internet cafe. And my Internet cafe was closed too. So I could not add a new post to my blog.


Don't worry. I keep on adding new posts to my blog. I didn't give up. I still have a lot that I want to say.


Text Screen Functions


In AutoLISP we have the following functions that can be used for giving an AutoLISP program a presentation. They are:


- Text screen functions
- Graphical screen functions
- Text functions
- Conversion functions


Now we are going to talk about the text screen functions. Later we are going to talk about the other functions.


(graphscr)
(textscr)


You can switch from the text screen to the graphic screen with the (graphscr) functions and go to the text screen with the (textscr) function.


System Variables


AutoCAD works with system variables. You can check the value of a system variable with the following function:


(getvar <variabele name>)


Examples:


(getvar “dwgname”) TEST
(getvar “cmdecho”) 1


Some system variables are read only. You cannot change their value. But if you can, you can change the value with:


(setvar <variable name> <value>)


Examples:


(setvar “filletrad” 200) 200
(setvar “cmdecho” 0) 0


It is advisable to set the system variable to its original value after the value has been changed. This is how it can be done:


(setq ce (getvar “cmdecho”)
(setvar “cmdecho” 0)
(setvar “cmdecho” ce)


Printing Data


(princ <expression> [<file description>])


This function writes the expression to the text screen and gives as a result the expression. The expression can be a text or a number.


The file description argument is optional and is used if the expression is written to an external file. We will talk about it later.


Examples:


(setq a 123)
(setq b '(a))


(princ 'a) A
(princ a) 123
(princ b) (A)
(princ “Hello”) “Hello”


If the expression is a text, then control codes can be added to it. The following control codes are available.


\\ the \ character
\e escape
\n new line
\r return
\t tab
\nnn the character with the octal code nnn


The PRINC function can also be used without an argument. Then an empty string is written to the screen. That is often at the end of a program.


Example:


(defun c:setng ()
(setvar “lunits” 4)
(setvar “blipmode” 0)
(princ)
)


After the AutoLISP program has been loaded into AutoCAD it is started by typing its name at the command prompt.


At the end of the AutoLISP program the command prompt is shown again without any additional information. There is no 0.


(prin1 <expression> [<file description>])


This function is the same as the previous function, but control codes are not evaluated.


Examples:


(setq a 123)
(setq b '(a))


(princ 'a) A
(princ a) 123
(princ b) (A)
(princ “Hello”) “Hello”


(print <expression> <file description>)


This function is the same as the previous function. But the expression is print on a new line and after the expression is a tab.


(prompt <text>)


Now you can only print a text to the text screen. The function prints the text and gives back nil.


Example:


(prompt “New value”) New value


Exercise


For this exercisxe the REPEAT function is used. Write an AutoLISP program, that draws five circles with the number of the circle in it.


This is the drawing that is created by the AutoLISP program.