I made a LISP to do a data extraction. But because the command line version of the DATAEXTRACTION command lacks in any options, what I ended up doing was making a workaround.
Because I only wanted certain attributed blocks, I set up a dxe template file with all the options I wanted, including all the blocks I want to extract, then saved this as dext.dxe in my C:\Temp folder. This command performs a SAVEAS to save the drawing as dext.dwg in the temp folder, performs the data extraction, then saveas it back to its original filename. It's not elegant, but it's the only way I could figure out how to automate the extraction with all the options I want.
Hope this helps!
(defun c:dext ( / *error* vars old dn dp dwg)
(princ "\nPlease wait while DEXT processes the BOM Table...")
(defun *error* ( msg );error handler
(and old (mapcar 'setvar vars old))
(or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
(princ (strcat "\n** Error: " msg " **")))
(setq vars '("CMDECHO" "FILEDIA") old (mapcar 'getvar vars))
(mapcar 'setvar vars '(0 0));set variables
(setq dn (getvar "dwgname"));get filename
(setq dp (getvar "dwgprefix"));get file path
(setq xls (vl-string-subst ".xls" ".dwg" dn))
(dos_copy "X:\\CONTROLLED_DOCUMENTS\\SYSTEMS\\ENGINEERING_DOCUMENTS\\AUTOCAD_STANDARDS\\Templates\\dext.dxe" "c:\\temp\\dext.dxe");copy dext.dxe from server to local to keep local copy up to date
(dos_copy "X:\\CONTROLLED_DOCUMENTS\\SYSTEMS\\ENGINEERING_DOCUMENTS\\AUTOCAD_STANDARDS\\Templates\\dext.xls" "c:\\temp\\dext.xls")
(dos_copy "X:\\CONTROLLED_DOCUMENTS\\SYSTEMS\\ENGINEERING_DOCUMENTS\\AUTOCAD_STANDARDS\\Templates\\dext.dwg" "c:\\temp\\dext.dwg")
(command "SAVEAS" "2010" (strcat "C:\\Temp" "\\" "dext.dwg") "YES");temporary directory for dummy dxe
(command "-dataextraction" "c:\\temp\\dext.dxe" "YES" "-75,75,0");perform the data extraction, place the table at a specific location in drawing
(command "_.DELAY" 7000);allows time for acad to write the xls file
(dos_copy "c:\\temp\\dext.xls" (strcat dp "..\\misc\\" xls));copy excel sheet to misc folder in project directory
(command "SAVEAS" "2010" (strcat dp dn) "YES");restore dwg to original directory
(mapcar 'setvar vars old);return variables
(princ "\nDEXT has successfully created the Item List")