See the top rated post in this thread. Click here

Results 1 to 3 of 3

Thread: Extraction of Text Data from AutoCAD LT

  1. #1
    Member
    Join Date
    2014-05
    Posts
    6
    Login to Give a bone
    0

    Default Extraction of Text Data from AutoCAD LT

    Short Story - I'm attempting to find a way to export the contents of all the text found on a certain layer in a drawing to Excel with out using blocks.

    Long Story:

    The company I work for mainly uses AutoCAD LT one of our main deliverables is Cutparts and Nestings. Small projects will hit the 300-400 part range big projects can go well over 1000.

    The issue is accurately checking that all the parts in one section are in the other. There's quick ways to do this and long ways to do this. The quickest way is running find to see how many items of text have what your looking for and comparing them, and the long way is sitting down with a couple people a literally mark things off as they're called out. The issue with the quick way is if you do think your missing a part it takes for ever to figure out which one it is, the issue with the long way is that it can take up to and over 3 days of time for 2 people over the course of a project.

    In a nut shell what I want to do is export/list the contents of all the text (MTEXT preferably) on layer "MARK-LABELS" in the cutpart layout drawings as line items, and do the same with the nesting drawings. Import/copy/stick them in Excel and run a simple match/count function to ensure everything is where it should be and if it's not what someone's missed or incorrectly copied. One of the reasons I want to stay away from blocks is that the nesting program we use (and some CNC programs) don't handle blocks and attributes all that well in that they explode the block causing the attribute to display the default and not the entered text (unless you use burst first which isn't available in AutoCAD LT) not to mention blocks as far as I'm concerned is a no no for CNC importing files.

    One of the things that was brought up is Data Extration, but from what I can figure this is only available in AutoCAD full and not LT. While we do have a couple seats floating in the office the main workhorse is LT which everyone has so I'd like to find a solution that works with LT.

    Any help would be appreciated - I feel like I'm missing something simple but I don't know what it is.

    Thanks

  2. #2
    Certified AUGI Addict jaberwok's Avatar
    Join Date
    2000-12
    Location
    0,0,0 The Origin
    Posts
    8,570
    Login to Give a bone
    1

    Default Re: Extraction of Text Data from AutoCAD LT

    Hi, welcome to AUGI.

    Since you do have a couple of full acad installations, the easy answer is most definitely - second/hijack one of them for this task.

    This lisp will probably do what you want.

    Code:
    -;
    ;  TXTOUT.LSP for AutoCAD R14
    ;  by John A Bogie, FactorEdge Ltd. August 1999.
    ;  Original code by by Tony Tanzillo, A/E Automation Systems
    ;  Public domain software for non-commercial use
    ;  Adapted from `export.lsp', part of `Misclisp' by Tony Tanzillo, A/E Automation Systems
    ;  `Export' is now a word reserved for AutoCAD's internal use. 
    
    
    
    ; --------------------------------------------------------------------
    ; TXTOUT.LSP & MTXTOUT  AutoCAD TEXT EXPORT FACILITY
    
    ;  TXTOUT & MTEXTOUT are user-defined lisp commands that will export
    ;  all text or all mtext entities in your drawing to any ascii text file you specify.
    ;  Each text entity in the drawing will occupy
    ;  one line in the file in the order that the text appears in the
    ;  drawing database.
    
    ;  To export the text in the drawing you are working on, simply
    ;  enter "txtout" <cr> at the AutoCAD command prompt.
    ;  To export the mtext in the drawing you are working on, simply
    ;  enter "mtxtout" <cr> at the AutoCAD command prompt.
    ;  You will then be asked for an OUTPUT filespec, which can be
    ;  any legal DOS file specification including drive, directory path,
    ;  filename and extension.
    ;  If the OUTPUT filespec already exists, you will be notified of
    ;  such, and told to start over and use another filespec. Once you
    ;  specify the filespec and it is accepted, the drawing database is
    ;  scanned and all text is exported to the specified file on an
    ;  entity-by-line basis (one line of text is written for each text
    ;  entity in the drawing, in the logical order in which they appear
    ;  in the database).
    
    :  Please note that I have tried to combine these two functions
    ;  into one. I have failed.
     
    (defun C:TXTOUT( / outfile)
      (if
        (and
           (not (eq "" (setq outfile (getstring "\nText output file: "))))
           (if (filep outfile)
             (prompt
               (strcat "\nFile " (strcase outfile)
                 " already exists, try again."))
            T)
           (setq outfile (open outfile "w"))
        )
        (progn
          (global 'object
            '(if (eq (get object 0) "TEXT")
               (write-line (get object 1) outfile)
            )
        t)
         (close outfile)
        )
      (if (not (filep outfile)) (prompt "\nInvalid filespec, try again."))
      )
      (prin1)
    )
    
    (defun C:MTXTOUT( / outfile)
      (if
        (and
           (not (eq "" (setq outfile (getstring "\nText output file: "))))
           (if (filep outfile)
             (prompt
               (strcat "\nFile " (strcase outfile)
                 " already exists, try again."))
            T)
           (setq outfile (open outfile "w"))
        )
        (progn
          (global 'object
            '(if (eq (get object 0) "MTEXT")
               (write-line (get object 1) outfile)
            )
        t)
         (close outfile)
        )
      (if (not (filep outfile)) (prompt "\nInvalid filespec, try again."))
      )
      (prin1)
    )
    
    ; support functions
    
    ; (entput <ename> <groupcode> <value> )
    ; Replaces or adds the specified <value> to the property specified
    ; by <groupcode> for the entity specified by <ename>.
    
    (defun entput(e p v / pr o)
      (setq pr (entget e))
        (entmod (if (setq o (assoc p pr))
          (subst (cons p v) o pr) (append pr (cons p v))
        )
      )
    )
    
    ; (filep <"filespec">)
    ; returns it's argument (a string) if a file with that name exists,
    ; and NIL otherwise.
    
    (defun filep(f / p)
      (cond ((setq p (open f "r")) (close p) f))
    )
    
    ; (global <alias> <procedure> <count>)
    ;
    ; Global will take <procedure> (any valid lisp expression) and apply
    ; it sequentially to each entity in the drawing, assigning each
    ; entity name to <alias>.
    ;
    ; If <count> is NON-NIL, then the message "Processing drawing database..."
    ; is printed on the display along the number of each entity as
    ; it is processed.
    ;
    ; Note: this procedure is very powerful (and should be used with caution).
    ;       It can be employed for many different purposes in the sense
    ;       that it can take the entire drawing entity-by-entity and
    ;       apply an "if-then-else" test for each entity and branch on
    ;       the result. You can use any valid LISP expression regardless
    ;       of the complexity (memory permitting) as the <procedure> argument,
    ;       and it will be applied to each entity in the drawing database.
    
    
    (defun global (smb expr count / i)
      (set smb (entnext))
      (setq i (if count 0))
      (prompt "\nProcessing drawing database... \n")
      (while
        (progn
          (if i (prompt (strcat "\rEntity " (itoa (setq i (1+ i))))))
          (eval expr)
          (set smb (entnext (eval smb)))
        )
      )
    )
    
    ; (get <ename> <property>)
    ;
    ; Returns the value of the specified <property> (which must be the
    ; group code of the desired property) from the entity specified by <ename>.
    (defun get(e g)
      (cdr (assoc g (entget e)))
    )
    ;--------------------------------------------------------------------
    (Prompt "\ntxtout and mtextout loaded")

  3. #3
    Member
    Join Date
    2014-05
    Posts
    6
    Login to Give a bone
    0

    Default Re: Extraction of Text Data from AutoCAD LT

    Thanks Jaberwok - sorry a got busy doing other things and left this to lie for a moment.

    That's awesome - so much less work than setting up an external reference.

Similar Threads

  1. Replies: 1
    Last Post: 2015-04-29, 01:18 PM
  2. GD205-4P: EAT TEXT: Data Extraction in AutoCAD® with Novacaine
    By Autodesk University in forum General Design
    Replies: 0
    Last Post: 2013-05-06, 01:41 AM
  3. Replies: 0
    Last Post: 2013-04-17, 04:42 AM
  4. 2012: AutoCAD Data extraction problem
    By jeff.smith in forum AutoCAD General
    Replies: 0
    Last Post: 2013-04-02, 01:07 PM
  5. Get Data Extraction to work as it did in AutoCAD 2007
    By kathy71046 in forum AutoCAD General
    Replies: 24
    Last Post: 2009-07-01, 07:51 AM

Posting Permissions

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