@mirqalib.m wrote:
This code worked. But I am copying the text from another program. It will take time to copy and insert the text and run the code. I am looking for a lisp that draws the text by copying and pasting it directly in autocada.
That may be time you need to take. How did you make the xy.txt file? By simply pasting what you copied out from the other program into a plain-text editor such as Notepad? If so, I don't see how what you want can happen by pasting into AutoCAD in that format.
In AutoCAD at the Command line, if I just copy the contents of your XY.txt file and paste them in, as should be obvious it starts right off with:
Command: 1 Unknown command "1". Press F1 for help.
Command: 322843.6900 Unknown command "6900". Press F1 for help.
... and so on. [I don't know why it takes only what follows the decimal point, but regardless....]
I can't picture any way to get what you want without something like an intermediary external file and AutoLisp routine to do the fishing for the pieces that are relevant, and the putting of them into the context of some drawing command(s), and the ignoring of the rest. Since that ignorable stuff is interspersed before and around and between the relevant stuff, it has to be something that can look at each line independently, so I can't imagine how a wholesale pasting of all of it could be interpreted into the right elements, without the content being in a file with separatable lines that it can take one at a time with something like the (read-line) function in my suggested code.
I wanted to try pasting wholesale in a way that AutoLisp could use without an external file. I copied to the clipboard the contents of your sample file. If I try to put it into a variable by pasting in answer to a (getstring) function, even allowing spaces, I get the first line into the variable, but only the first line, and then it goes back to the Command prompt so the next piece of content sends it into unknown-command mode.
There may be a way I don't know about to have it construct such a file out of pasted-in content, and then process that file. But the way to put text into a file is (write-line), which writes out text strings, so I think it would also depend on (getstring) for input, and that can't take the whole content at once.
I'd be interested in anyone else's notions about how to get multiple-line text content like what's in xy.txt collectively into a single variable so AutoLisp could try to do something with it without an external file.
Kent Cooper, AIA