how to LISP routine reads text and print to csv file

how to LISP routine reads text and print to csv file

Anonymous
Not applicable
1,438 Views
3 Replies
Message 1 of 4

how to LISP routine reads text and print to csv file

Anonymous
Not applicable

Hi guys,

I know this task is simple but I'm very rusty on autolisp... I do not remember anything of it, **** Smiley Sad


I've a directory with 2000 dwgs and I need to extract 2 text from any of them and print all on a csv file.


All these dwgs have the texts (simple text) I need at precise coordinates.

Text 1 is at 291.3835, 21.7590, 0.0000
Text 2 is at 337.8941, 10.9997, 0.0000

So basically I need a routine that "reads" the content of Text 1, reads the content of Text 2 and prints these two contents in a row in a csv file, then close the current dwg and process the next one till all dwgs of the directory specified are done.

 

I hope to have been clear... Thanks in advance to all want to help me.

0 Likes
1,439 Views
3 Replies
Replies (3)
Message 2 of 4

martti.halminen
Collaborator
Collaborator

This can be divided into three main parts:

 

1. Read the texts in one drawing

- see the documentation about the SSGET function.

- dig the actual string out of the result 

 

2. Write the texts to the .csv file

- open the file for appending

- write the first text

- write a separator

- write the other text

- close the file

 

3. repeat for the next drawing

- Here the main problem is that usually AutoCAD is ran with the Windows Multiple Document Interface setting. In this case each drawing has its own Lisp environment, so a single Lisp program can't work on multiple drawings without some contortions. There are two common ways to avoid this:

A. handle the stepping between drawings from an external program

B. change to using Single Document Interface for this task.

 

For a one-off task that is all; if this is a recurring task you might try building this to use AutoCAD Core Console for better performance.

0 Likes
Message 3 of 4

dbhunia
Advisor
Advisor

Hi,

 

I am agree with your steps.... except the highlighted ones......

 


@martti.halminen wrote:

This can be divided into three main parts:

 

1. Read the texts in one drawing

- see the documentation about the SSGET function.

- dig the actual string out of the result 

 

2. Write the texts to the .csv file

- open the file for appending

- write the first text

- write a separator

- write the other text

- close the file

 

3. repeat for the next drawing

- Here the main problem is that usually AutoCAD is ran with the Windows Multiple Document Interface setting. In this case each drawing has its own Lisp environment, so a single Lisp program can't work on multiple drawings without some contortions. There are two common ways to avoid this:

A. handle the stepping between drawings from an external program

B. change to using Single Document Interface for this task.

 

........................

 

By taking care of two system variables "SDI" & "LISPINIT" you can work on multiple drawings using a single Lisp Program at a time......


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 4 of 4

martti.halminen
Collaborator
Collaborator

 

What did you think case B was?

 

--

 

0 Likes