Jump to content

Extracting dimensions and prefixes autolisp


whoolieshop

Recommended Posts

Good Evening!

 

I have a lisp script that exports dimension values to a csv file.

I have modified it to only export selected dimensions which is exactly what I want.

However;

I would also like to export any prefix the dimension has and include it with the exported dimension:

 

EG:    a dimension of 36" that has a prefix of R should be something like   R - 36,     a dimension with no prefix would just be 36

Attached is my current lisp script:

 

; Save the Dimension's values to a CSV file
; mfuccaro@hotmail.com
; 2008 May
; Enhancements by CAD Studio, 2012
; Modified by WhoolieShop to include prefix's and only work on current selection.
;
(setq _dimexpdelimiter ",") ; set to ";" for CSY/DEU...

(defun C:DimExp ( / s tx fn i d dl m file)

(setq s (ssget  (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)
)

 

Thanks in advance!

Edited by whoolieshop
more info added.
Link to comment
Share on other sites

Okay about 3 hours of tinkering have gone by and if i change 42 to 1 I can get any overridden text pulled out, and if I change it to 3, i can get the dimension style names which could totally work.

 

How would I go about editing this code around the line with 42 to include,   Option 42 AND option 3?  (dimension style names)   Note I also need duplicates exported, NOT grouped together if there are 40 dimensions exported and 20 are the exact same I need 40 values exported to the csv.

 (setq d (ssname s (setq i (1- i)))
	dl (entget d)
	m (cdr (assoc 42 dl)))
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...