Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Attribute Extraction routine

  1. #1
    Member
    Join Date
    2006-02
    Posts
    13
    Login to Give a bone
    0

    Default Attribute Extraction routine

    Hi every one. I have a question: When I use the attribute extract wizard (typing "eattext") on the option "select drawings"; it leaves out 3 of the 9 files I need to process. All these files have the block I need to extract info from. It kind of suggests that the eattext command is limited to a certain number of files to process, the problem is that the files it leaves out are not the last ones but in a random fashion along the list as the Autocad browser shows them. Once the process is done and eattext is applied to the files it left out the first time it processes them with no problems. Any Ideas? I am using Autocad 2005. Looking for a solution:
    I found the following lisp routine to do this and its instructions. The problem is that it extracts info from all the blocks with attributes on the drawings processed, it writes a column for the attribute value and another one with the attribute tag to the right of the first one -this may be a matter of interchanging two rows of code-, and it would be nice if it put the tags as titles of columns and the data under each column.
    The instructions are:
    "To process a few drawings drag the lisp file icon in the drawing area. The program will auto start.
    A possible usage for batch processing: open a new drawing, go to TOOLS > AutoLisp > LOAD� and in the "Load/Unload Application" window locate the lisp file and drag it in the Startup Suit. Now this program will be loaded in every drawing. Close the window and go to FILE > OPEN. Select all the files you wish to process (hold shift/Ctrl to select multiple files) and press OPEN. Relax and watch the screen. After the last file opened search the file C:attributes.CSV and open it with Excel. Probable a double-click on the file will make it open in Excel, but that also depends on your settings.
    If a dwg contains no blocks with attributes you will see an error message in the AutoCAD command line. Please ignore it.
    And don't forget to remove the program from the Startup Suit!

    P.S. Without an adequate filter the program will extract all your attributes -including the data in the title data block, date stamp and so on.

    The code is:
    Code:
     ; Global ATTribute EXtractor
     ; by Miklos Fuccaro mfuccaro@hotmail.com
     ;-------------------------November 2004 -------
    (defun gattex ()
      (setq ss (ssget "X" '((0 . "INSERT") (66 . 1))))
      (if (not ss)
    	(quit)
      )
      (setq	file (open "c:attributes.CSV" "a")
    	i	-1
      )
      (write-line
    	(strcat (getvar "DWGPREFIX")
    		(getvar "DWGNAME")
    		" -found "
    		(itoa (sslength ss))
    		" block(s) with attributes"
    	)
    	file
      )
      (repeat (sslength ss)
    	(setq l (entget (setq e (ssname ss (setq i (1+ i))))))
    	(write-line
    	  (strcat "block name:" "," (cdr (assoc 2 l)))
    	  file
    	)
    	(while (/= (cdr (assoc 0 l)) "SEQEND")
    	  (if (= (cdr (assoc 0 l)) "ATTRIB")
    	(write-line
    	  (strcat ",," (cdr (assoc 1 l)) "," (cdr (assoc 2 l)))
    	  file
    	)
    	  )
    	  (setq l (entget (setq e (entnext e))))
    	)
      )
      (close file)
      (princ)
    )
    (gattex)
    It seems that the editor takes out the tab and spaces at the begining of each row. I hope it does not make a difference.
    I know I may sound too picky but the truth is I don't know any programing or Lisp. Can someone please help?
    Thank you for your time.

    [ Moderator Action = ON ] What are [ CODE ] tags... [ Moderator Action = OFF ]
    Last edited by Mike.Perry; 2006-03-02 at 09:21 PM. Reason: [CODE] tags added.

  2. #2
    The Silent Type Mike.Perry's Avatar
    Join Date
    2000-11
    Posts
    13,656
    Login to Give a bone
    0

    Default Re: Attribute Extraction routine

    Hi "ivan_sosa_b" ( Sorry, I do not know your real name )

    Please note I have *moved* this thread from the AutoCAD Customization forum to this one, as I believe it will be better served here.

    Thanks, Mike

    Forum Moderator

  3. #3
    Member
    Join Date
    2006-02
    Posts
    13
    Login to Give a bone
    0

    Default Re: Attribute Extraction routine

    Thank you. You are right. I think I did not see this option.

  4. #4
    I could stop if I wanted to tyshofner's Avatar
    Join Date
    2004-03
    Location
    Dallas, Tx
    Posts
    229
    Login to Give a bone
    0

    Default Re: Attribute Extraction routine

    Hello ivan,

    Here is an edited version of the code, what I changed is in red, and where you see "YOURBLOCKNAME" is where you would need to place the name of the block you want to filter for. I also adjusted the writing of the "*.csv" file so that the "tag" is in the first column with its value to the right, and I removed the "blockname" portion. (not sure if thats what you wanted or not, but it's a start).

    Code:
     
     ; Global ATTribute EXtractor
     ; by Miklos Fuccaro mfuccaro@hotmail.com
     ;-------------------------November 2004 -------
    (defun gattex ()
      (setq ss (ssget "X" '((0 . "INSERT") (2 . "YOURBLOCKNAME") (66 . 1))))
      (if (not ss)
     (quit)
      )
      (setq file (open "c:attributes.CSV" "a")
     i -1
      )
      (write-line
     (strcat (getvar "DWGPREFIX")
      (getvar "DWGNAME")
      " -found "
      (itoa (sslength ss))
      " block(s) with attributes"
     )
     file
      )
      (repeat (sslength ss)
     (setq l (entget (setq e (ssname ss (setq i (1+ i))))))
    ;;; (write-line
    ;;;   (strcat "block name:" "," (cdr (assoc 2 l)))
    ;;;   file
    ;;; )
     (while (/= (cdr (assoc 0 l)) "SEQEND")
       (if (= (cdr (assoc 0 l)) "ATTRIB")
    	 (write-line
    	   (strcat (cdr (assoc 2 l)) "," (cdr (assoc 1 l)))
    	   file
    	 )
       )
       (setq l (entget (setq e (entnext e))))
     )
      )
      (close file)
      (princ)
    )
    (gattex)
    Ty

  5. #5
    Member
    Join Date
    2006-02
    Posts
    13
    Login to Give a bone
    0

    Default Re: Attribute Extraction routine

    Hi. tyshofner!
    It still takes the information from all the blocks with attributes.
    when Autocad opens the drawings it shows an error on the message area that reads:
    AutoCAD menu utilities loaded.; error: misplaced dot on input
    What do you think is wrong?

  6. #6
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Attribute Extraction routine

    Try to change
    (open "c:attributes.CSV" "a")
    to
    (open "c:\\attributes.CSV" "a")

    or check other lisp that loads at startup
    you can drag'n drop lispfiles in to AutoCAD to find the file that cause the error

    : ) Happy Computing !

    kennet
    Last edited by kennet.sjoberg; 2006-03-03 at 07:43 PM.

  7. #7
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Attribute Extraction routine

    . . . or try this
    Code:
    ;;; Global ATTribute EXtractor
    ;;; by Miklos Fuccaro mfuccaro@hotmail.com
    ;;; ------------------------November 2004 ------- Modified in 2006
    (defun gattex (/ SelSet File#1 Counter EntName EntDxf )
      (if (setq SelSet (ssget "X" '((0 . "INSERT") (2 . "YOURBLOCKNAME" ) (66 . 1 )))) ;; <-- Change "YOURBLOCKNAME" to appropriate BlockName
        (progn
          (if (setq File#1 (open "c:\\attributes.CSV" "a" ) )
            (progn
              (setq Counter -1 )
              (write-line (strcat (getvar "DWGPREFIX" ) (getvar "DWGNAME" ) " -found " (itoa (sslength SelSet )) " block(s) with attributes" ) File#1 )
              (repeat (sslength SelSet )
                (setq EntDxf (entget (setq EntName (ssname SelSet (setq Counter (1+ Counter ))))) )
                (while (/= (cdr (assoc 0 EntDxf )) "SEQEND" )
                  (if (= (cdr (assoc 0 EntDxf )) "ATTRIB" )
                    (write-line (strcat (cdr (assoc 2 EntDxf )) "," (cdr (assoc 1 EntDxf ))) File#1 )   ; Comma
    ;; if TAB       (write-line (strcat (cdr (assoc 2 EntDxf )) "	" (cdr (assoc 1 EntDxf ))) File#1 ) ; Tab
                    ( )
                  )
                  (setq EntDxf (entget (setq EntName (entnext EntName ))) )
                )
              )
              (close File#1 )
              (princ "Done ! " )
            )
            (princ ". . file not found " )
          )
        )
        (princ "No legal block found " )
      )
      (princ)
    )
    (gattex)
    : ) Happy Computing !

    kennet
    Last edited by kennet.sjoberg; 2006-03-03 at 08:24 PM. Reason: TAB option

  8. #8
    Member
    Join Date
    2006-02
    Posts
    13
    Login to Give a bone
    0

    Default Re: Attribute Extraction routine

    Hi, kennet.sjoberg!
    The change you proposed still takes info from all blocks. It generates a set of the desired data on different columns though; and you can manipulate the data some what.
    Since it seems it cannot be told to read only from one block; can we tell it to specifically not read from the other blocks?

  9. #9
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Attribute Extraction routine

    What are the names of the blocks you want to read the attributes from? That is the information the people need to help you.

  10. #10
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Attribute Extraction routine

    Quote Originally Posted by ivan_sosa_b
    Hi, kennet.sjoberg!
    The change you proposed still takes info from all blocks. It generates a set of the desired data on different columns though; and you can manipulate the data some what.
    Since it seems it cannot be told to read only from one block; can we tell it to specifically not read from the other blocks?
    Yes, the program is designed to take all block with the same name
    Do you want to manually select one of them ?
    or a couple ?
    or one at a specific coordinate ?
    is the block name not necessary ?

    : ) Happy Computing !

    kennet
    Last edited by kennet.sjoberg; 2006-03-03 at 08:38 PM.

Page 1 of 2 12 LastLast

Similar Threads

  1. Attribute extraction routine
    By draftsit in forum AutoLISP
    Replies: 1
    Last Post: 2009-03-04, 07:32 PM
  2. Attribute Extraction 2
    By lee.johnson in forum AutoLISP
    Replies: 2
    Last Post: 2009-01-13, 04:27 PM
  3. Attribute Extraction
    By jim.temple in forum AutoLISP
    Replies: 8
    Last Post: 2006-11-10, 01:54 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
  •