AutoCAD/Text Attribute or automation question
Expert: Scott Cook - 3/24/2011
QuestionQUESTION: I work with Carlsson Survey over the top of AutoCad, and In my work I often need to have text that has hatched underlining, below it and rather that drawing a line below the text, I use text in a string such as, %%uA%%u %%uB%%u %%uC%%u %%uS%%u %%uT%%u %%ur%%u %%ue%%u %%ue%%u %%ut%%u, which displays very much the way I want it to and when editing you never need do go back and change a line drawn below it.
I am looking for a time saving way to have, say, a dialogue box in which i can type in the text and it will automatically place the %%u %%u around it rather than having to type it all out manually? Is this possible or are there other ways to do this that you know of?
Thanks
ANSWER: So just to be clear you want to have the underline on each letter, not each word or the entire sentence?
In any case, it would be easy to make a lisp routine to do that by taking a text input and concatenate the %%u on either end of each letter or the entire string. I could guide you through that learning process if you like. It's probably about 6 lines of code.
---------- FOLLOW-UP ----------
QUESTION: Yes you are correct, each letter, and I would be interested in your help in doing the code to achieve this?
AnswerOk, I will try to help you. I assume you know how to use a text editor like notepad. Autocad has a built-in editor for programming you can reach by typing VLIDE at the command line.
You will need to locate the autolisp function reference in the autocad help files and lookup the following functions that will be required to complete the job:
Defun
Getstring
Strlen
While
Substr
Strcat
Command
What I envision is defining your own command within the lisp routine with a (defun c:mycommand ()
Then proceeding with
Prompting for text to input
Get the length of the string
Set a counter starting with the first character in the string
Loop while there are characters left
Get each char with subtr
Append the underlines with strcat to each side of each char, building up the string
Increment the counter
Close the loop
Output it with the text command
That's about it for now. Let me know if you have further questions (I'm sure you will).