Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp needed extract text to file for wire labels

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
knj777
4819 Views, 10 Replies

Lisp needed extract text to file for wire labels

Hi All,

I'm hoping someone can assist me with a LISP routine, or otherwise, to extract text from drawing to either notepad or excel.

It sounds simple, but I have researched for ways to do this that would fit for our company and I havent found such a thing.

The trick we need is to take the wiring diagram wires ( dtext ) and put it in an order as it appears on the drawing, so we can print them to lables.

I've attached a drawing that I think shows this pretty good.

 

We currently run a lisp routine that does do this. However, we have to pick each pieice of text, on at a time, so it is in that order to for notepad (which is then imported to excel, then to the lable making machine).

 

We are running Acad 2009, but will upgrade to 2012 in a few months.

Any suggestions will be greatly appreciated!

 

Thanks!

10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: knj777

Hopefully this post will help you in what you are looking for.  if not, I remember the an old asctext.lsp and a textout.lsp.  You can google for those or do a search on this forum to see if they are here.

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Looking-for-a-method-to-copy-autocad-...

Message 3 of 11
3wood
in reply to: knj777

You can try TEXT2CSV, which can convert texts/llines to a csv file in a format just as you wanted.

Before you run it, please do some preparation works:

1. explode all polylines to lines.

2. Use "TJUST" (in Express Tools) to format all text to BL alignment.

Then select objects as shown red below, the red lines are going to define the rows and lines of the excel file.

Text2csv01.jpg

 

And here is the result I have got:

Text2csv02.jpg

 

But you need get a free registration of the add-on to remove the 2-lines only restriction.

 

 

3wood

CAD KITS

Message 4 of 11
jsowinski
in reply to: knj777

Hi-

I put together a routine that will allow you to select a diagram one at a time by placing a window around it. The function stays open to select more diagrams until you either hit a return or escape. Follow the prompts at the command line. When you are done hit return and the routine will automatically open the txt file for review. The txt file is placed into the same directory as the drawing you run the routine in. At the moment every time you run the program it will overwrite the previous txt file. If you want to append the file instead just change this line in the routine.

 

(setq fname (open fn "w"))  to (setq fname (open fn "a"))

 

Jiim

 

Message 5 of 11
knj777
in reply to: 3wood

3Wood, Thanks for the great solution! Unfortunelty I wasnt able to try this at work because of the lack of visual basic. While trying it out at home, I was able to run it, but ran the trial version. It gave me excatly what I was looking for. I understand the company is possibly looking into gettting us visual basic, so this may be a great solution to our problem at hand.

 

Thanks

knj777

Message 6 of 11
knj777
in reply to: jsowinski

Jim,

Wow, great lisp! Exactly what I've been looking for. I do have some questions/concerns though. I've attached a drawing that shows this. But I can explain alittle here.

First off, when I ran it, I selected all the text around all the devices. It worked good, but didn't put them in the order I was looking for. When I ran the routine and selected one device at a time, (which is the way I believe you intended) it worked wonderful.

Is there a way to select all the device text and have it in the order I am looking for? Or, if I did select one device at a time, can it keep adding that text to the txt file, so we could get all of, lets say, Unit 1" wiring inside one document?

 

I know very little about writing lisp routines. But I'm real curious as to how it's written and how it knows to grab some text, but not all? Which is a good thing, I am just wondering if you have it set to pick text by a layer or justification or something else?

 

Thanks for your time

knj777

 

 

Message 7 of 11
jsowinski
in reply to: knj777

knj777-

I'm glad you like the routine. In a nutshell, the function looks for the layer and justification of the text and sorts them by their vertical position. The left and right sides are sorted separately and then written to the text file. The reason why I chose to process the diagrams separately was to prevent everything from sorting into one list. (which you discovered) This was the quick and easy way of handling all of the text. I'll take a look at re-sorting the information. In the mean time I've attached a modified version of the lisp to process your diagrams in a horizontal position. Same process of selecting one diagram at a time. (command is "Hlabels") Feel free to change any of the names or commands to make it easier for you to understand.

 

Jim

 

Message 8 of 11
knj777
in reply to: jsowinski

Jim,

Thanks for the horizontal label routine. It works great. Is it likely you could get the lisp to grab all text of a row (or column) of all diagrams (devices) in one drawing? That would be the ideal soultion for us, although we do appreciate the routine you supplied.

 

thanks

knj777

 

Message 9 of 11
jsowinski
in reply to: knj777

knj777-

Well, I think I got it. (third times a charm) This will work on the horizontal diagrams just like the previous one I sent. The command is the same as the last ("Hlabels"). You can now select the entire drawing in two picks or you can still select multiple diagrams while the function is open. The routine will still overwrite the old text file every time you launch the routine unless you make the change to append it as I described it in a previous posting. I did have one observation on your example drawing. The bottom diagram has the header (FB) in the middle unlike the others which have it at the top. The lisp reads all of the text from left to right with the headers (A, B, FA, FB) as the location to set the labels under. Because the FB is in the middle it only sees the text to its right when reporting it. The remaining text in that diagram is reported with the FA header. Try it you'll see what I mean. I hope that works for you.

 

Jim

 

Message 10 of 11
knj777
in reply to: jsowinski

Thank You VERY Much! Smiley Very Happy

We are very happy with this lisp you wrote!

 

knj777

Message 11 of 11
jsowinski
in reply to: knj777

You're welcome! I'm glad you like it.

 

Jim

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost