Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bypass AutoCAD Data extraction wizzard

5 REPLIES 5
Reply
Message 1 of 6
gary_s_wright
2834 Views, 5 Replies

Bypass AutoCAD Data extraction wizzard

Can anyone help me....?

 

I'm looking to create a LISP routine that can run the data extraction command, referencing a pre-determined dxe template file in order to quickly create a linked table of data retrieved from dynamic block information.

 

Basically, I'm looking to bypass the 8 step data extraction wizard command, in order to prevent the user from selecting the incorrect information and speed up the process.

 

I have found a decent code written by user "BlackBox" called DEXT posted "2012-06-27, 02:46 PM" link below:

http://forums.augi.com/showthread.php?140476-EXTRACT-ATTRIBUTE-DATA-FROM-SELECTED-OBJECTS-amp-CREATE...

 

BlackBox's DEXT LISP routine, requires you to create a C\temp folder and place a dwg containing the blocks you wish to extract and a template dxe file.

This routine works ok the first run, however, it fails on any consecutive run due to the dwg library file being over written.

Can either of you lisp wizards fix this DEXT command or know of another process that can achieve this?

Any help with this will be greatly appreciated.

5 REPLIES 5
Message 2 of 6
Moshe-A
in reply to: gary_s_wright

Gary Hi,

 

do not understand why the lisp creator SAVEAS the current dwg to a temporary folder and restore it after dataextraction, i do not see the need

so i erased those code lines as you requested but i did not test it (do not have dos_lib modula)

 

be aware if you change the dxe template file the function might not work.

 

 

(dos_demandload) ;LOADS THE DOSLIB FILES

(defun c:dext ( / *error* vars old dn dp dwg) ; RUN DEXT AT THE COMMAND PROMPT
  
  (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 " **")))
    (princ)
  )

  (setq vars '("CMDECHO" "FILEDIA") old (mapcar 'getvar vars))
  (mapcar 'setvar vars '(0 0));set variables

  (setq dn (getvar "dwgname"))  	;get filename ;GETS THE FILENAME SO IT CAN RESAVE THE FILE WHEN IT'S DONE RUNNING
  (setq dp (getvar "dwgprefix"))	;get file path ; GETS THE PATH SO IT SAVES IT IN THE RIGHT PLACE

  (dos_copy "c:\\temp\\dext-orig.dxe" "c:\\temp\\dext.dxe")		;keep copy of dext.dxe fresh and up to date
  (command "-dataextraction" "c:\\temp\\dext.dxe" "YES" "-75,75,0")	;perform the data extraction, place the table at a specific location in drawing
  
  (mapcar 'setvar vars old);return variables
  (princ "\nDEXT has successfully created the Item List")
  (princ);exit quietly
)

 

cheers

moshe

Message 3 of 6
cadffm
in reply to: Moshe-A

"do not understand why the lisp creator SAVEAS the current dwg to a temporary folder and restore it after dataextraction, i do not see the need"

In a DXE File is stored the DWG-Pathes/Files hardcoded, so you can you a created DXE only for the files you have selected by this one workflow.

 

How the program works

 

create a dxe for one dummy-DWG (c:\temp\dext.dwg)

Now you can use this DXE for (only) this one file, thats why bb SAVEAS current file to c:\temp\dext.dwg

 

SAVEAS is simple but bad solution

GOOD: The targetfile is equal to current file content, which could be unsaved.

BAD: It saved my drawing, but i dont like it every time..

 

Much better is a function like command SAVE

(command save via script or the copy all content via odbx)

Sebastian

Message 4 of 6
gary_s_wright
in reply to: Moshe-A

Moshe,

 

Thank you so much for your imput.

 

I'll give this a test run as soon as i can.

 

However, the major benifit to the code from "BlackBox" was that it does'nt require DOSlib.

 

If its not doable without DOSlib then I may have to convince my IT departrment to install it across our AutoCAD users.

 

 

 

Message 5 of 6
Moshe-A
in reply to: gary_s_wright

Gary,

 

Just remembered, there is an old AutoCAD method to extract data from drawings

if you only intrested in extracting block and attributes, you could use ATTEXT command.

it require to create a template file of *.txt type which is pure text and it's output is also text file which could be a CDF (Comma Dlimited) file.

that Excel can open and make a table of it.

 

Are you intersted in such things?

 

Moshe

 

 

 

Message 6 of 6
scooberu
in reply to: gary_s_wright

Thank you for this discussion. I know I am late to the party on this, but I am trying to do something similar. I would also like to prevent the user(s) from using the wizard, but I would like them to confirm proper dxe file, correct files to be extracted from, and correct save location. Alas, the wizard seems to be all or nothing. 

 

In my case, a single dxe will be copied & customized by someone who knows what it is, but the extraction update can be done by anyone. It also seems that CMDECHO and FILEDIA are irrelevant!  (-dataextraction)  works regardless, so several lines of code can be eliminated. The "Y" in the command is permission to overwrite the previous csv. I would prefer to back up the previous one, but this works for now.

 

Note that the command to run the extraction is one line only. All the other code is collecting paths & file names.

 

(defun C:PIEXT (/ dp dxepath dxefile) ; 
  (setq dp (getvar "dwgprefix")) ; get file path 
  (setq dxepath (strcat dp "PI_Data\\DummyFile")) ; Set ppath to search the proper directory
  (setq dxefile (getfiled "Confirm DXE file" dxepath "dxe" 8)) ; Get user input to confirm correct .dxe file
 
  (command "-dataextraction" dxefile "Y") ; Run Data Extraction 
  (princ "If the extraction is misplaced or incomplete, edit the dxe file")
  (princ) ; Exit Quietly
)

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report