Page 2 of 5 FirstFirst 12345 LastLast
Results 11 to 20 of 41

Thread: EXTRACT ATTRIBUTE DATA FROM SELECTED OBJECTS & CREATE TABLE IN MODEL SPACE

  1. #11
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: EXTRACT ATTRIBUTE DATA FROM SELECTED OBJECTS & CREATE TABLE IN MODEL SPACE

    Here you go, I've modified it a bit to omit making an xls file and added some notes that should help you.

    First thing you need to do is create a drawing in "C:\Temp" and save it as "dext.dwg". Include ANY blocks that you want to perform the data extraction on (from any of your dwgs). Once you've done this, make a dxe file using the regular, dialogue-driven DATAEXTRACTION command. Set all the options that you want (select all the attributed blocks you want to get info from). Save this dxe file as "dext.dxe". So basically, you've got a dext.dwg and a dext.dxe in the c:temp folder. In the temp directory, make a copy of dext.dxe and call it dext-orig.dxe

    You only have to do this once to set up the data extraction template. I don't know what version of acad you're running, so check the command line version of SAVEAS to assure that it saves as "2010".

    As for DOSLib, just make sure those files are in your support path. This loads it when you run DEXT.

    And, I forgot to mention, the error handling doesn't work, so don't hit escape or anything while it runs (it takes a few seconds).

    Let me know if it works for you!

    Code:
    (vl-load-com) ;LOADS VISUAL LISP COMPONENTS
    (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
    
    ;(setq xls (vl-string-subst ".xls" ".dwg" dn))
    
    (dos_copy "c:\\temp\\dext-orig.dxe" "c:\\temp\\dext.dxe");keep copy of dext.dxe fresh and 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 THIS IS WHERE IT SAVES YOUR DRAWING TO C:\TEMP
      
    (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")
      (princ);exit quietly
      )

  2. #12
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: EXTRACT ATTRIBUTE DATA FROM SELECTED OBJECTS & CREATE TABLE IN MODEL SPACE

    FWIW - There's no need for DOSLib:

    vl-File-Copy
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #13
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: EXTRACT ATTRIBUTE DATA FROM SELECTED OBJECTS & CREATE TABLE IN MODEL SPACE

    I thought I needed DosLib to allow me to overwrite the excel files, otherwise it'll only append. I don't know jack about VL, so I don't know if vl-file-copy will allow for deletion/overwrite. If you can, that'd be easier than working with DosLib.

  4. #14
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: EXTRACT ATTRIBUTE DATA FROM SELECTED OBJECTS & CREATE TABLE IN MODEL SPACE

    You're correct that vl-File-Copy only allows for append if the destination file already exists, but one can use an IF statement to test for the destination file using FINDFILE, and if the file exists to use vl-File-Delete prior to using vl-File-Copy.

    Withholding the overwrite functionality is a flaw IMO.
    Last edited by RenderMan; 2012-06-27 at 02:57 AM.

  5. #15
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: EXTRACT ATTRIBUTE DATA FROM SELECTED OBJECTS & CREATE TABLE IN MODEL SPACE

    Ah, okay, I wasn't aware of the delete function. Thanks

  6. #16
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: EXTRACT ATTRIBUTE DATA FROM SELECTED OBJECTS & CREATE TABLE IN MODEL SPACE

    Happy to help

  7. #17
    100 Club
    Join Date
    2006-11
    Location
    Martinsburg, WV USA
    Posts
    199
    Login to Give a bone
    0

    Default Re: EXTRACT ATTRIBUTE DATA FROM SELECTED OBJECTS & CREATE TABLE IN MODEL SPACE

    I still can not get it to work? I have the LISP loaded, but the command line returns "Unknown command "DEXT""

  8. #18
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: EXTRACT ATTRIBUTE DATA FROM SELECTED OBJECTS & CREATE TABLE IN MODEL SPACE

    Quote Originally Posted by james.126519 View Post
    I still can not get it to work? I have the LISP loaded, but the command line returns "Unknown command "DEXT""
    Hmm, I'm not sure. Did a cursory check and everything seems to be okay... If you've loaded it, I don't really know why you'd get that error.

  9. #19
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    Default Re: EXTRACT ATTRIBUTE DATA FROM SELECTED OBJECTS & CREATE TABLE IN MODEL SPACE

    Can you re-post your modifed code (the one without DOSLIB) so the rest of us can have a look-see.

  10. #20
    Design Visualization Moderator stusic's Avatar
    Join Date
    2004-10
    Location
    Denver, Colorado
    Posts
    1,515
    Login to Give a bone
    0

    Default Re: EXTRACT ATTRIBUTE DATA FROM SELECTED OBJECTS & CREATE TABLE IN MODEL SPACE

    Quote Originally Posted by pbejse View Post
    Can you re-post your modifed code (the one without DOSLIB) so the rest of us can have a look-see.
    I haven't modified it. I could use the IF statements with Vlips as suggested, but I've already got DosLib in place and distributed, so I didn't bother. I still use the code from my first post.

Page 2 of 5 FirstFirst 12345 LastLast

Similar Threads

  1. Replies: 7
    Last Post: 2011-11-18, 12:08 PM
  2. Replies: 2
    Last Post: 2010-03-23, 07:22 PM
  3. Extract Attribute Data into a Table
    By KansasCAD in forum AutoCAD Tables
    Replies: 1
    Last Post: 2006-04-21, 02:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •