Jump to content

find some particular texts and expoting them into csv automatic without a dialogbox


ernestkwarteng

Recommended Posts

Please the attached cad contains a drawing and a table with text and below is some reference id .My problem now is how to extract the text in the table and the reference number at the bottom right to csv.please can anyone help me with a script to do dat .i have several dwgs which i would like the script to loop through that folder and extract them to individual csv .thanks .

text.dwg

Link to comment
Share on other sites

What have you tried so far? Have you got a method at all that can write something to a dwg?

 

I'd start by trying to write one piece of text to csv and then build from there, rather than trying to do several different pieces of info on several drawings straight away.

Link to comment
Share on other sites

A couple of things it not a "Table" its lines around text, try to use correct wording for objects makes it easier to provide a response.

 

This should be pretty close. It does have an extra step sort on Y in excel but it was done in 2004

; converts column of text to comma seprated file with text value and y value
; put in excell and sort by y value
; by Alan H Nov 2004
(setq x 1)
(while (/= x 4)
 (setq howmany (rtos x 2 0))
 (setq fileto (strcat "c:/temp/setout" howmany))
 (princ fileto)
 (setq fout (open fileto "w"))
 (while (not (setq ss (ssget ))))     
(princ "wow")
   (while (setq en (ssname ss 0))
    ; Entity type
    (setq entyp (cdr (assoc 0 (entget en)))) 
(princ "wow")
   (if (= entyp "TEXT")
   (progn
     (setq xyz (cdr (assoc 10 (entget en))))
     (setq txtht (cdr (assoc 1 (entget en))))
     ;write file out here
     (setq textout (strcat txtht "," (rtos (cadr xyz) 2 3)))
     ;write
     (write-line textout fout) 
     (princ textout)
   )                         
   )                              
   ; Delete each measured entity from set
   (ssdel en ss)
 ;end while
 )
 (close fout)
 (setq x (+ x 1))
) ;end if loop 3 times
(princ)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...