An lisp routine that export autocad text to excel

Recommended Posts


CafeJr

Community Regular

CafeJr

    • Share

:? Guys,

I need one help, someone knows one Lisp that I can get Texts (words) on AutoCad and export it in order of selection to a cell on Excel…

Eg.: If I have 10 words, as I’ll selecting it and when finished these then words will be exported to a cell (could be cels) to Excel.

Thanks in advance…

  • Quote

Link to comment
Share on other sites


Tharwat

Grand Master

Tharwat

    • Share

Can you explain your goal with an example ?

Are you wanting to select one by one to keep them in the same order exported to Excel ?

  • Quote

Link to comment
Share on other sites


BIGAL

Grand Master

BIGAL

    • Share

Getexecl.lsp it is a library of excel-autocad functions both ways.

GetExcel.zip

  • Quote

Link to comment
Share on other sites


CafeJr

Community Regular

CafeJr

  • Author
    • Share

Can you explain your goal with an example ?

Are you wanting to select one by one to keep them in the same order exported to Excel ?

In these picture In trying to clarify the task.

Tharwat, the selection is one by one, because I have a Big drawing with a lot of information, and I need to follow the names and select it to export by selection order. To show the example I put A and B, but it’s only to exemplify, not is necessary to work with two collumns or two line of cells, only get the words and export it to Excel in order of selection, it will help a lot.

Text exported by order selection to Excel.jpg


Edited January 10, 2015 by CafeJr

  • Quote

Link to comment
Share on other sites


CafeJr

Community Regular

CafeJr

  • Author
    • Share

Getexecl.lsp it is a library of excel-autocad functions both ways.

Thanks Bigal, I will try it too.

  • Quote

Link to comment
Share on other sites


BIGAL

Grand Master

BIGAL

    • Share

Your request is two parts, actually writing to excel is the easy bit and thinking about provide you always use A C C etc it can be done.

Thinking about it now if you just make a list of text (A-1 B-1 B-3 A-2 ETC ) You can take 1st character and check if its A B C D etc and set column (asc(text)) last number A-23 = 23+row offset = cell row so if some missing will jump over blanks. B-23 = cell 2,27

Thanks to Lee-mac for this it will give a number as an answer.

; use say nth of your list of text selected (setq nthtext (nth x testlist))
; to use (setq cellnum (Lm:parsenumbers nthtext))

;;-------------------=={ Parse Numbers }==--------------------;;
;;                                                            ;;
;;  Parses a list of numerical values from a supplied string. ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  s - String to process                                     ;;
;;------------------------------------------------------------;;
;;  Returns:  List of numerical values found in string.       ;;
;;------------------------------------------------------------;;

(defun LM:ParseNumbers ( s )
 (
   (lambda ( l )
     (read
       (strcat "("
         (vl-list->string
           (mapcar
             (function
               (lambda ( a b c )
                 (if
                   (or
                     (< 47 b 58)
                     (and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
                     (and (= 46 b) (< 47 a 58) (< 47 c 58))
                   )
                   b 32
                 )
               )
             )
             (cons nil l) l (append (cdr l) (list nil))
           )
         )
         ")"
       )
     )
   )
   (vl-string->list s)
 )
)

  • Quote

Link to comment
Share on other sites


CafeJr

Community Regular

CafeJr

  • Author
    • Share

Sorry Bigal, the text at AutoCad, isn’t a specific address to Excel, it’s any kind of text, to be exported to Excel in «any» cell. I didn’t pay attention on AutoCad text that I wrote… similar a Excel cell address…

  • Quote

Link to comment
Share on other sites


pBe

Grand Master

pBe

    • Share

Getexecl.lsp it is a library of excel-autocad functions both ways.

:thumbsup: Cool lisp rouitne

  • Quote

Link to comment
Share on other sites


CafeJr

Community Regular

CafeJr

  • Author
    • Share

Getexecl.lsp it is a library of excel-autocad functions both ways.

Bigal, I don’t know why, but I loaded the Getexcl lisp but it doesn’t work, the command isn’t recognized. I did it in two AutoCad softwares, 2012 and 2013 versions…

  • Quote

Link to comment
Share on other sites


Tharwat

Grand Master

Tharwat

    • Share

Bigal, I don’t know why, but I loaded the Getexcl lisp but it doesn’t work, the command isn’t recognized. I did it in two AutoCad softwares, 2012 and 2013 versions…

The GetExcel.lsp is a function to deal to Excel files that release after the year 2003 and which their extension files would be formatted to .xls and xlsx … etc so this function alone does not help you with any .

Anyway , I have a plan to write a program with a dialog box to obtain the selected text strings before exporting them to txt format or Excel file with a format .csv . Would this be suitable for your needs ?

I am busy at the moment but would write it since that I think it would be handy program in general .

Tharwat

  • Quote

Link to comment
Share on other sites


CafeJr

Community Regular

CafeJr

  • Author
    • Share

Thank you Tharwat… I don’t know if it’s simple, but the idea is, is only collect a spread texts (words) in a drawing in order of selection… to export it to Excel.

  • Quote

Link to comment
Share on other sites


Tharwat

Grand Master

Tharwat

    • Share

Thank you Tharwat… I don’t know if it’s simple, but the idea is, is only collect a spread texts (words) in a drawing in order of selection… to export it to Excel.

Try this program and let me know .

Note: At the end of selecting texts , just press enter and type ( n ) or ( no ) to display the dialog for the last process .

(defun c:Test  (/ *error* _dialog dlg s name s l k save path o)
;;;        Tharwat 13.01.2015        ;;
 (defun *error*  (msg)
   (if (and dlg (findfile dlg))
     (vl-file-delete dlg)
     )
   (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*"))
     (princ (strcat "n** Error: " msg " **"))
     )
   (princ)
   )
 (defun _dialog  (/ id f)
   (cond
     ((not
        (and
          (setq dlg (vl-filename-mktemp nil nil ".dcl"))
          (setq f (open dlg "w"))
          (write-line
            "test : dialog {label = "Test Strings"; width = 40;
            : text { key = "path"; }
            spacer_1 ;
            : list_box { key = "lst"; height = 18;}
            : boxed_row {
            : button { label = "Okay"; key = "oki"; width = 12;}
            : button { label = "Exit"; key = "esc"; is_default = true; is_cancel = true; width = 12;}
            : button { label = "Save to"; key = "sv"; width = 12;}
            }}"
            f
            )
          (not (close f))
          )
        )
      (alert "Can't load the temporary file <!>")
      )
     ((or (not dlg)
          (not (> (setq id (load_dialog dlg)) 0))
          (not (new_dialog
                 "test"
                 id
                 )
               )
          )
      (princ "n Can not load Dialog !")
      )
     (t
      (start_list "lst")
      (mapcar 'add_list (reverse l))
      (end_list)
      (mode_tile "oki" 1)
      (set_tile "lst" "0")
      (action_tile
        "sv"
        "(if (setq path (getfiled "Save to" (getvar 'DWGPREFIX) "csv" 1))
             (progn
             (set_tile "path" path)
             (mode_tile "oki" 0))
           (mode_tile "oki" 1))"
        )
      (action_tile
        "oki"
        "(setq save t)(done_dialog)"
        )
      (action_tile "esc" "(setq save nil)(done_dialog)")
      (start_dialog)
      (unload_dialog id)
      (vl-file-delete dlg)
      )
     )
   save
   )
 (while
   (cond
     ((and (setq s (car (entsel "n Pick Texts :")))
           (wcmatch (cdr (assoc 0 (entget s))) "TEXT,MTEXT")
           )
      (setq l (cons (cdr (assoc 1 (entget s))) l))
      )
     ((or s (not s))
      (princ "nInvalid Selection !! Select text ONLY ")
      (initget 6 "Yes No")
      (or (not (setq k
                      (getkword "n Missed !! Continue [Yes/No] <Yes> :")))
          (eq k "Yes")
          )
      )
     )
   )
 (if (and l (setq save (_dialog)) (setq o (open path "w")))
   (progn
     (mapcar '(lambda (x) (write-line x o)) (reverse l))
     (close o)
     (princ "n Well done ...")
     )
   (princ "n Exit by User ")
   )
 (princ)
 )




  • Quote

Link to comment
Share on other sites


CafeJr

Community Regular

CafeJr

  • Author
    • Share

Woowwwww… He he he… Thanks Tharwat!… It Works as good as I need!!!…

The unique «delay» that I have it’s work with spreadsheets (by the number of usages), I’m thinking if has a way to fill up one spreadsheet only (I don’t know), or using a Ram memory to copy these texts to paste one a cell in a Excel file open… It’s that possible?…

  • Quote

Link to comment
Share on other sites


Tharwat

Grand Master

Tharwat

    • Share

Woowwwww… He he he… Thanks Tharwat!… It Works as good as I need!!!…

I am happy that you liked the program ;)

The unique «delay» that I have it’s work with spreadsheets (by the number of usages), I’m thinking if has a way to fill up one spreadsheet only (I don’t know), or using a Ram memory to copy these texts to paste one a cell in a Excel file open… It’s that possible?…

I don’t think that I got your point :unsure:

  • Quote

Link to comment
Share on other sites


CafeJr

Community Regular

CafeJr

  • Author
    • Share

Sorry,

Let me try to explain!…

Every time that I use it, I’ll create a spreadsheet (it’s ok, no problem, it’s help a lot even why I need to rewrite the path on Excel!).

It’ll be used to follow electrical cables on a drawing, think in one electrical installation I have one point (origin) and a target of the cable (instruments on the field), so, I have to do these follow the path texts (address of electrical pipes or cable trays) to select where the cable pass through, are many cable to do it one by one, you got it?…

Installation.jpg

  • Quote

Link to comment
Share on other sites

Join the conversation

You can post now and register later.

If you have an account, sign in now to post with your account.

Note: Your post will require moderator approval before it will be visible.

Visual LISP, AutoLISP and General Customization


Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.


Showing results for 


Search instead for 

Did you mean: 


  • Back to forum


  • Previous

  • Next

Tom Holderfield

724 Views, 17 Replies

‎02-02-2007

09:46 AM

Text from AutoCAD to Excel


Does anyone have or know where I can get a Lisp routine that will extract text from AutoCAD to paste into Excel when the text is not an attribute? We have a rather extensive database of drawings that I need to get B.O.M.’s from. I can do it one piece of text at a time, but it’s kind of a slow process.


  • Back to forum


  • Previous

  • Next

17 REPLIES 17

Fatty

‎02-02-2007

12:13 PM

Can you upload the sample drawing
with some explanations, maybe I can help

~’J’~

EC-CAD

‎02-02-2007

01:28 PM

Here’s one I have. Works for me.
You will have to ‘tune’ it to suit.
:)

Bob

EC-CAD

‎02-02-2007

01:32 PM

I also have one that does text extract, based on Window
locations (definable in program).
Will do multiple drawings, as long as the ‘bom’ falls in
the same spot, and is Horizontal layout.

E-Mail: nospam.ec-cad@centurytel.net
(remove the ‘nospam’ and the ‘.’ to EMail.

Bob

Tom Holderfield

‎02-02-2007

02:39 PM

Thanks Bob,
I did send you an e-mail.

Tom Holderfield

‎02-02-2007

02:44 PM

Thanks for replying. I am attaching a typical BOM for one of our drawings. What we are trying to accomplish is getting all the text in «one» copy & paste, if you will, and placing it into an Excel spreadsheet.

Fatty

‎02-02-2007

03:24 PM

I’ll try to do it tomorrow

~’J’~

Fatty

‎02-03-2007

02:16 AM

Try this too, see an explanations inside the code
before you’ll ran it
Still waiting for feedback :slightly_smiling_face:

~’J’~

EC-CAD

‎02-03-2007

05:32 AM

Sorry, got busy yesterday.
I sent you a response, and a ‘new’ GP
Lisp for your bom layout.

:)
Bob

civil82

‎02-04-2007

08:09 AM

I thinks this lisp what you need.

Tom Holderfield

‎02-05-2007

09:04 AM

J,

I tried it this morning, but I must have done something wrong. I got an error message that said «malformed list on input» and I’m not sure what that means.

Fatty

‎02-05-2007

09:28 AM

Sorry, my bad
I’m lost a parenthsis there
Try this instead
(Shame on me)

~’J’~

Tom Holderfield

‎02-05-2007

09:41 AM

J,

I still got the same message, but it look a little different on how it displays. Does that make sense?

Fatty

‎02-05-2007

09:55 AM

I think case is on the table have an
empty cells, populate these cells
with «-» symbol or with another one
and try again
Forgot to say about the table could’t
have the merged cells also, exclude the header
Btw I tested on your attached drawing, works
fine for me
(A2005 only)
Still watching this thread

Hth

~’J’~

Tom Holderfield

‎02-05-2007

10:03 AM

J,

Eash time I try to load via «appload» I get the error. I’m using 2004

Fatty

‎02-05-2007

10:11 AM

I am an idiot again, I don’t save changes
in prior lisp, sorry
Try another one

:)

Tom Holderfield

‎02-05-2007

10:30 AM

J,

Awesome…..You are the man!!

Thanks soooo much.

Tom

Fatty

‎02-05-2007

01:33 PM

Glad if that helps
Happy computing
Cheers :slightly_smiling_face:

Fatty, The Stupid Old Horse

~’J’~


  • Back to forum


  • Previous

  • Next

Решение!

  1. Во-первых, нам нужно преобразовать наши текстовые объекты в один объект Mtext. …
  2. Теперь, когда у нас есть один объект Mtext с несколькими текстовыми строками, мы можем дважды щелкнуть по нему, выделить все содержимое и нажать «Копировать» (Ctrl + C).
  3. Мы можем запустить Microsoft Excel и вставить туда наши данные.

Как экспортировать данные из AutoCAD в Excel?

Решение:

  1. В командной строке AutoCAD введите TABLEEXPORT .
  2. При появлении запроса выберите таблицу, которую вы хотите экспортировать.
  3. Введите желаемое имя файла и сохраните файл в формате CSV.
  4. Откройте полученный CSV-файл в Excel.
  5. Отформатируйте таблицу по желанию.
  6. Сохраните файл как файл XLS или XLSX.

Как экспортировать текст из AutoCAD?

Вы можете копировать тексты по отдельности с помощью копирования/вставки. Для экспорта текста из ваших чертежей вы также можете использовать утилиту перевода текста CADstudio TRANS. Альтернативой является утилита Txt2Xls (см. Загрузка), которая экспортирует тексты в Excel.

Как скопировать текст из AutoCAD в Word?

Откройте текстовый редактор в AutoCAD, выделите текст, который хотите скопировать, щелкните его правой кнопкой мыши и выберите «Копировать» или нажмите (управление) «C». Откройте новое слово Doc и вставьте его.

Извлечение данных с помощью AutoCAD

  1. На вкладке «Вставка» есть панель «Связывание и извлечение». …
  2. В этом случае я впервые извлекаю данные из этого рисунка, поэтому я выберу «Создать новое извлечение данных». …
  3. Затем я могу выбрать, из каких рисунков извлекать данные.

Создание новой таблицы извлечения данных

  1. Выберите вкладку «Аннотации» панель «Таблицы» «Извлечь данные». …
  2. На странице «Начало» нажмите «Создать новое извлечение данных». …
  3. В диалоговом окне «Сохранить извлечение данных как» введите имя файла для извлечения данных и нажмите «Сохранить».

Как экспортировать координаты AutoCAD для точек в MS Excel с помощью LISP?

Загрузите lisp (узнайте, как загрузить lisp в файл CAD, чтобы узнать больше о lisp, нажмите и выполните следующую инструкцию.

Экспорт точек из AutoCAD в Excel в виде точек на север и на восток

  1. Загрузите lisp, набрав в командной строке AP.
  2. Введите в командной строке ( Click2XLS )
  3. Файл Excel откроется автоматически.
  4. Нажмите ввод и инструкции на экране потока.

Как преобразовать текст в Mtext в AutoCAD?

Из текста в Mtext

Выберите «Экспресс»> «Текст»> «Преобразовать текст в многострочный текст». В приглашении Выбрать объекты: выберите текстовые объекты, которые вы хотите преобразовать. Если вы вместо этого нажмете Enter, вы получите диалоговое окно Text to MText Options. Установите нужные параметры и нажмите OK.

Как редактировать таблицу Excel в САПР?

В Microsoft Excel выберите область электронной таблицы, которую вы хотите импортировать, и скопируйте ее в буфер обмена. В AutoCAD в меню «Правка» выберите «Специальная вставка». В диалоговом окне «Специальная вставка» выберите параметр «Объекты AutoCAD». При этом создается таблица AutoCAD, которую можно отформатировать в соответствии с типом линии и стилем текста.

Export Text from a Drawing to an Excel Spreadsheet C:Txt2Xls is a LISP command for exporting text from a drawing to an Excel spreadsheet. This command will attempt to locate text in columns based on your selection criteria. Start by loading the LISP code and typing Txt2Xls at the Command line. The program first will attempt to link with the Excel application, which must exist on your computer. Next, the program will ask you to select text using two points to define a rectangular window. Only text objects will be selected inside this window. In the next step, the program asks you to select to sample text objects from the same column. These text objects will be used to determine a deviation factor for locating columns of text (that way your text does not have to be exactly lined up, just close). The rest is automatic as the text objects are extracted and written to a new workbook inside Excel. This program is very cool when it works, but make sure you have Excel installed. You might need to edit the code yourself for specific versions of Excel — for help, visit Cadalyst’s Hot Tip Harry-Help Discussion Forum.

The following procedure allows you to copy text from AutoCAD and paste it in excel as a text.


Autocad:

First copy and stack the text in a column. Go to “express tools” and select convert text to mtext. now select all the text and click enter. All the texts are now a single entity and a multiitext. 

Copy the text file and paste it in an excel sheet. The text will be in one cell and in a horizontal line.

Excel:

This is how the text will appear when pasted in a excel sheet in order to arrange the text in separate rows ,go to DATA tab and click on TEXT TO COLUMNS icon and select DELIMITED option.

Tick on “Space” and then select next. Then finish

Now all text will be in separate horizontal cells (row)

Now in order to arrange the text in a column, select the entire row 1 and then select COPY.

Click on any other cell and then right click to select PASTE SPECIAL


In the dialogue box select TRANSPOSE  as shown and then OK


Repeat this procedure as required.

Note: When Text to column once selected in a cell (cell 1a) and the contents in that cell is deleted and another content is pasted in the same cell, it is not required to repeat the procedure (sorting of text in different cells) again.

Like this post? Please share to your friends:
  • An informal word for also
  • Also first word sentence
  • An informal word for a conversation
  • Alsm excel to internal table
  • An explanation of the meaning of a word is known as