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

Export value of text to Excel (sometimes error)

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
minh.dxuan
2112 Views, 8 Replies

Export value of text to Excel (sometimes error)

Dear all,

 

Now I am using the lisp (T2E) to export value list of texts in CAD to Excel. Normally it runs OK but sometimes the error occurs and I must restart the computer to try to run this lisp again. Even sometimes I restarted computer but this error still occurred again and I can not continue my work.

I really need your help to fix this problem. Please review the attached lisp and video with error for me.

 

Thank you so much and best regards.

8 REPLIES 8
Message 2 of 9
Ajilal.Vijayan
in reply to: minh.dxuan

Looks like the Express tools module is not loaded or missing.

try the steps in here

https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/expres... 

Message 3 of 9
minh.dxuan
in reply to: Ajilal.Vijayan

Hi @Anonymous

 It seems that there is error with the lisp. Please try to export text value to Excel file with attached drawings. 

Many thanks.

Message 4 of 9
hosneyalaa
in reply to: minh.dxuan

 

HI 

TEST THIS

;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-value-of-text-to-excel-sometimes-error/td-p/9764877
(defun C:T2E(/ FN FW I J LST STR)
(princ "\nChon cac Text/Mtext/Dimension can xuat ra file...")
  (IF (AND
(setq lst (mapcar 'entget (acet-ss-to-list (ssget '((0 . "*TEXT,DIMENSION"))))))
   (setq	fn (getfiled "Chon file de save" "" "csv" 1))
   (setq	fw (open fn "w") i 0 j 0)
)
  (PROGN
(foreach n lst
;;;  (setq n (CAR lst))
(princ
 (cond
  ((wcmatch (cdadr n) "*TEXT")(strcat (setq str (vlax-get (vlax-ename->vla-object (CDR(ASSOC -1 N))) 'Textstring)) ";Text" (itoa (setq i (1+ i))) "\n"))  
  ((= (cdadr n) "DIMENSION")(strcat (if (= (acet-dxf 1 n) "")(rtos (acet-dxf 42 n))(acet-dxf 1 n))  ";Dim" (itoa (setq j (1+ j))) "\n"))
 )
  fw
 )
 )
(close fw)
  (startapp "explorer" fn)
))
  )

 

 

Message 5 of 9
hosneyalaa
in reply to: hosneyalaa

Capture.JPGHI

Message 6 of 9
minh.dxuan
in reply to: hosneyalaa

Hi @hosneyalaa ,

 

With almost Section Drawings, I still can extract text values to Excel file but with this Station Drawing and some few other drawings, this error always occurs. I am using AutoCAD 2021. Please review the photo with error for me. Thank you so much.

 
Message 7 of 9
hosneyalaa
in reply to: minh.dxuan

HI

 

TEST 

 

;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/export-value-of-text-to-excel-sometimes-error/td-p/9764877
(defun C:T2E(/ FN FW I J LST STR)
(princ "\nChon cac Text/Mtext/Dimension can xuat ra file...")
  (IF (AND
(setq lst (mapcar 'entget (LM:ss->ent (ssget '((0 . "*TEXT,DIMENSION"))))))
   (setq	fn (getfiled "Chon file de save" "" "csv" 1))
   (setq	fw (open fn "w") i 0 j 0)
)
  (PROGN
(foreach n lst
;;;  (setq n (CAR lst))
(princ
 (cond
  ((wcmatch (cdadr n) "*TEXT")(strcat (setq str (vlax-get (vlax-ename->vla-object (CDR(ASSOC -1 N))) 'Textstring)) ";Text" (itoa (setq i (1+ i))) "\n"))  
  ((= (cdadr n) "DIMENSION")(strcat (if (= (acet-dxf 1 n) "")(rtos (acet-dxf 42 n))(acet-dxf 1 n))  ";Dim" (itoa (setq j (1+ j))) "\n"))
 )
  fw
 )
 )
(close fw)
  (startapp "explorer" fn)
))
  )




;;--------------=={ SelectionSet -> Entities }==--------------;;
;;                                                            ;;
;;  Converts a SelectionSet to a list of Entities             ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  ss - Valid SelectionSet (Pickset)                         ;;
;;------------------------------------------------------------;;
;;  Returns:  List of Entity names, else nil                  ;;
;;------------------------------------------------------------;;

(defun LM:ss->ent ( ss / i l )
    (if ss
        (repeat (setq i (sslength ss))
            (setq l (cons (ssname ss (setq i (1- i))) l))
        )
    )
)

Capture.JPG

Message 8 of 9
minh.dxuan
in reply to: hosneyalaa

Dear @hosneyalaa ,

 

I tried your new lisp and it run well. I would like to thank you so much for your help. Wish all the best with you.

 

Sincerely Yours.

Message 9 of 9
hosneyalaa
in reply to: minh.dxuan

You're welcome anytime.

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

Post to forums  

Autodesk Customer Advisory Groups