Jump to content

Extract text Label and Dimension's to a CSV file


BrianTFC

Recommended Posts

No need Lee. I just search on how to use some commands and change the program you provided. Thanks!

 

 

 

 

(defun c:asd ( / des dim enx idx sel txt )

 

(setq code (getint "\n Input Number of glass marking ") )

 

(repeat code

 

(setq code_txt (strcat "\n Code left to click: " (itoa code) " "))

(princ "\n")

(princ code_txt)

(setq code (- code 1))

 

 

(if (and (setq sel (ssget '((0 . "TEXT,MTEXT,*DIMENSION"))))

(setq qty (getint "\n Input Quantity ") )

(setq qty (itoa qty))

 

(setq des (open (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME)) ".csv") "a"))

 

;(strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME)) ".csv")

;use this to get filename of cad file

 

)

(progn

(repeat (setq idx (sslength sel))

(setq enx (entget (ssname sel (setq idx (1- idx)))))

(if (wcmatch (cdr (assoc 0 enx)) "*DIMENSION")

(setq dim (cons (rtos (cdr (assoc 42 enx)) 2 0) dim))

(setq txt (cons (cdr (assoc 1 enx)) txt))

 

)

)

(while (or dim txt)

(write-line

(strcat

(cond ((car txt)) ("")) ","

(cond ((cadr txt)) ("")) ","

(cond ((car dim)) ("")) ","

(cond ((cadr dim)) ("")) ","

(cond (qty) (""))

) ;strcat

des

)

(setq txt (cddr txt)

dim (cddr dim)

)

)

)

)

);repeat

(if (= 'file (type des)) (close des))

(princ)

 

);defun

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...