AutoLISP Programming: A LISP to edit your text objects with number entries
Print This Post
![]() |
Author | M. Derya Bahceci |
| Profession | Civil Engineer | |
| Location | Ankara, TURKEY | |
All AutoLISP versions
Hi to all,
Since this is my fist article on this site, I want to share a LISP, which I have created in the very beginning of my AutoCAD history. The aim of the program is to search a defined area and perform mathematical operations in the found text objects with number entries. I have written this program because I have had to change lots of elevation entries since the datum is set wrong. Since chancing them one by one means a serious time, it helped me a lot. I hope it will help you too.
Let us first define the program. ‘cx’ ,as a shortcut, is selected to run the command. I generally choose close keys that is nothing assigned to them.

Code-1
I wanted to run the command in a closed area that I designated instead of the whole drawing. So the next thing is defining a polygon and having the search processed inside.
Do not forget, you have to define the last point in a way that the polygon should include the first point otherwise, process plots an error.
To allow this, I have written the lines below:

Code-2
The point here is listing the text objects in ‘E’ layer found in the designated area in ‘sspoint’ variable and saving them into database. ‘E’ letter in the line (cons 8 “E”) stands for the layer. You can change it with the one you want. You will understand the process better when you examine the lines.
To assign the number of the found text objects to a variable that is going to be used in upcoming loop operation; we have to know the length of sspoint list. So I just write the related command.
![]()
Code-3
If some text objects exist in the area defined, the ‘ssl’ variable will be an integer. Let us use it and create a loop.

Code-4
The operation in this example is subtracting ‘0.30’ from the value. You can change it as you like. Do not forget; if the content of text object selected is letters, not numbers, the program just replaces it with ‘-0.30’. So, the objects with number entries should be formed in a different layer.
To end the program we have to make the parenthesis equal.
![]()
Code-5
You can understand the program better if you run it in AutoCAD step by step. For instance, just write down the polygon part of the program, run it and check the results. And then make the list and so on. Studying LISP files step by step always gives better results.
Regards.
Related file:
- 4islem.lsp (English version)
Technorati Tags:
A random post
