Export dimension from Cad to Excel

Export dimension from Cad to Excel

UShakya1
Observer Observer
570 Views
2 Replies
Message 1 of 3

Export dimension from Cad to Excel

UShakya1
Observer
Observer

Hello, I need some guidance on updating a lisp file I found online (shared below). I am very new to lisp files. I want to export cad dimensions to excel. Following lisp file does that but it does not export all the dimensions. When there are multiple same dimension, it just export one of that dimension. For example: I need to export (5) dimensions but it export only (4) dimensions as it is exporting only one 11'-11.25" even though there are two of them. I would appreciate the help to solve this. Thank you.

UShakya1_0-1683214413842.png

;
(setq _dimexpdelimiter ",") ; set to ";" for CSY/DEU...

(defun C:DimExp ( / s tx fn i d dl m file)
(setq s (ssget "_X" (list '(0 . "DIMENSION")))
tx nil
fn (strcat (getvar "dwgprefix") "DimExp.csv"))
(repeat (setq i (sslength s))
(setq d (ssname s (setq i (1- i)))
dl (entget d)
m (cdr (assoc 42 dl)))
(if (not (member m tx)) (setq tx (cons m tx)))
)
(setq s nil)
(if tx (progn
(setq file (open fn "a")) ; append
(write-line "" file)
(princ (strcat (getvar "dwgname") _dimexpdelimiter) file)
(foreach x tx
(princ x file)
(princ _dimexpdelimiter file)
)
(if file (close file))
(princ (strcat "\n" (itoa (length tx)) " dimensions written to " fn))
))
(princ)
)

0 Likes
571 Views
2 Replies
Replies (2)
Message 2 of 3

komondormrex
Mentor
Mentor

hey,

maybe that

 

(setq _dimexpdelimiter ",") ; set to ";" for CSY/DEU...
(defun C:DimExp ( / dim_sset fn file)
	(if (setq dim_sset (ssget "_X" (list '(0 . "DIMENSION"))))
		(progn
			(setq fn (strcat (getvar "dwgprefix") "DimExp.csv")
				  file (open fn "a") ; append
			)
			(write-line "" file)
			(princ (strcat (getvar "dwgname") _dimexpdelimiter) file)
			(foreach dim (vl-remove-if 'listp (mapcar 'cadr (ssnamex dim_sset))) 
				(princ (cdr (assoc 42 (entget dim))) file)
				(princ _dimexpdelimiter file)
			)
			(if file (close file))
			(princ (strcat "\n" (itoa (length tx)) " dimensions written to " fn))
		)
	)
	(princ)
)
Message 3 of 3

UShakya1
Observer
Observer

Thank you that worked. Appreciate your input.

0 Likes