Results 1 to 5 of 5

Thread: Iserting attributes from a text file

  1. #1
    Member
    Join Date
    2016-10
    Posts
    2
    Login to Give a bone
    0

    Default Iserting attributes from a text file

    Hello all,
    The company I am working at has replaced their titleblock a few times over the years for various reasons ie.. logo change, required attribute information changing, etc.. I have cobbled together a lisp routine to
    1. update the attribute tags using code from this post

    2. export the data into a tab delimited file using modified code from the attout.lsp and calling some functions in that lisp.

    3. remove and purge the old titleblocks and replace the the blocks with the updated version.

    Now the part I am stuck on is replacing the attribute information. if I use attin i can select the txt file and manually select the files assuming I know what order they were selected in on the extraction. I am currently making my selections with this piece of code
    Code:
    (setq BLKLST(ssget "x" (LIST(CONS 2 "MAR4"))))
    . I use this for all the selections throughout the process so it will always select in the same order. I would like to make the selection to replace the attributes the same way.

    as a side note these are multi sheet isometrics with all the sheets in model space.

    Any help would be greatly appreciated

  2. #2
    Member Jim_Fisher's Avatar
    Join Date
    2015-12
    Location
    Texas
    Posts
    31
    Login to Give a bone
    0

    Default Re: Iserting attributes from a text file

    Lee Mac (www.lee-mac.com) has some great attribute management functions. Just type 'Attributes' in the search field. Take a look on there and see if there's something that can do what you're looking for. If not, come back here and let us know.

    Jim
    ~ Hamburgers! The cornerstone of any nutritious breakfast. ~

    ~ Mind if I try one of yours? This is yours here, right? ~

    ~ Mmm-mmmm. That is a tasty burger. ~

  3. #3
    Member
    Join Date
    2016-10
    Posts
    2
    Login to Give a bone
    0

    Default Re: Iserting attributes from a text file

    Thanks I did get tunnel vision because the attout.lsp works good with few modifications for getting the attributes out automagicaly. I guess I got stuck on that path. I have used things from Lee-Mac previously, he has very good stuff. I will rethink my code with the tools he has. My goal is to make this process of steps as automatic as possible because the company wants the titleblocks updated and the designers refuse to take the time to do so as they think it is a waste of time (they are correct manually doing so is labor intensive). If I get this to work the way I envision even non-drafters and non-designers will be able to perform the work.

    thanks for setting my focus back in a better direction.

  4. #4
    Member Jim_Fisher's Avatar
    Join Date
    2015-12
    Location
    Texas
    Posts
    31
    Login to Give a bone
    0

    Default Re: Iserting attributes from a text file

    Quote Originally Posted by gumbeau View Post
    If I get this to work the way I envision even non-drafters and non-designers will be able to perform the work.
    Keep me posted on how you do. I fear I'll be traveling down this same road in the near future.

    Quote Originally Posted by gumbeau View Post
    thanks for setting my focus back in a better direction.
    No problem. We all need a push in the right direction now and again.

    Jim
    ~ Hamburgers! The cornerstone of any nutritious breakfast. ~

    ~ Mind if I try one of yours? This is yours here, right? ~

    ~ Mmm-mmmm. That is a tasty burger. ~

  5. #5
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    561
    Login to Give a bone
    0

    Default Re: Iserting attributes from a text file

    I have various full update all title blocks and its not that hard, you know the name of the block and the name of all the attribute tags. This is an example, the only tricky bit is that as you have all title blocks in model space where as I take advantage of the layout tab name D01 D02 etc. So you would get all the blocks check attribute sheet number then update from your new list.

    Hope this helps

    Code:
    ; update a specific dwg job title block info
    ; change the 410 to layout name
    
    ;;-------------------=={ Parse Numbers }==--------------------;;`
    ;;                                                            ;;
    ;;  Parses a list of numerical values from a supplied string. ;;
    ;;------------------------------------------------------------;;
    ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
    ;;------------------------------------------------------------;;
    ;;  Arguments:                                                ;;
    ;;  s - String to process                                     ;;
    ;;------------------------------------------------------------;;
    ;;  Returns:  List of numerical values found in string.       ;;
    ;;------------------------------------------------------------;;
    
    (defun LM:ParseNumbers ( s )
      (
        (lambda ( l )
          (read
            (strcat "("
              (vl-list->string
                (mapcar
                  (function
                    (lambda ( a b c )
                      (if
                        (or
                          (< 47 b 58)
                          (and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
                          (and (= 46 b) (< 47 a 58) (< 47 c 58))
                        )
                        b 32
                      )
                    )
                  )
                  (cons nil l) l (append (cdr l) (list nil))
                )
              )
              ")"
            )
          )
        )
        (vl-string->list s)
      )
    )
    
    
    
    ;(defun ah:sheetupdate1 ( /  LEN ss1 lay plotabs tabname sheetnum )
    (defun ah:sheetupdate1 ()
    
    (SETVAR "REGENMODE" 0)
    
    (setq doc (vla-get-activedocument (vlax-get-acad-object)))
    (vlax-for lay (vla-get-Layouts doc)
      (setq plotabs (cons (vla-get-name lay) plotabs))
    )
    
    (setq dwgname "2010026")
    (setq bname "DA1DRTXT")
    
    (setq plotabs (vl-remove "Model" plotabs))
    (setq plotabs (vl-remove "PlotPreview" plotabs))
    
    (setq oldtag1 "SHT_NO") ;attribute tag name
    
    (setq oldtag2 "DRG_NO") ;attribute tag name
    
    (setq oldtag3 "PROJ_NO") ;attribute tag name
    (setq newstr3 "2010026")
    
    (setq oldtag4 "REV_NO") ;attribute tag name
    (setq newstr4 "PA")
    
    (setq oldtag5 "PROJECT_DESCRIPTION") ;attribute tag name
    (setq newstr5 "SEALING OF ROADS")
    
    (setq oldtag6 "PROJECT_TITLE") ;attribute tag name
    (setq newstr6 "NORTH ")
    
    (setq oldtag7 "DIRECTORY") ;attribute tag name
    (setq newstr7 "MELWAYS")
    
    (setq oldtag8 "MAP_REF") ;attribute tag name
    (setq newstr8 "444&445")
    
    (setq oldtag14 "SHEETS") ;attribute tag name
    (SETQ NEWSTR14 (rtos (length plotabs) 2 0)) 
    
    (setq oldtag15 "STREET") ;attribute tag name
    (setq newstr15 "NORTH )
    
    (setq oldtag16 "SUBURB") ;attribute tag name
    (setq newstr16 "ROAD SEALING")
    
    (setq oldtag18 "DESIGNER") ;attribute tag name
    (setq newstr18 "A H")
    
    (setq oldtag19 "DRAFTER") ;attribute tag name
    (setq newstr19 "A H")
    
    (setq oldtag20 "SHT_SIZE") ;attribute tag name
    (setq newstr20 "A1")
    
    (foreach tabname plotabs 
          ; no need to regen each sheet
          ;(setvar "ctab" tabname)
          ;(command "pspace")
    
          (setq ss1 (ssget "x"  (list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname))))
          (setq dwgnum (Lm:parsenumbers tabname))
          (setq sheetnum (car dwgnum))
          (setq newstr1 sheetnum)
    
        ; if less than 10
        (if (< (car dwgnum) 10.0) 
          (setq newstr2 (strcat dwgname "-D0" (rtos sheetnum 2 0)))
          (setq newstr2 (strcat dwgname "-D"  (rtos sheetnum 2 0)))
        )
          (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 0 )) 'getattributes)
     
           (if (= oldtag1 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr1) 
            ) ; end if
            (if (= oldtag2 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr2) 
            ) ; end if
            (if (= oldtag3 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr3) 
            ) ; end if
            (if (= oldtag4 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr4) 
            ) ; end if
            (if (= oldtag5 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr5) 
            ) ; end if
            (if (= oldtag6 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr6) 
            ) ; end if
            (if (= oldtag7 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr7) 
            ) ; end if
            (if (= oldtag8 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr8) 
            ) ; end if
            (if (= oldtag14 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr14)
            )
            (if (= oldtag15 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr15)
            )
            (if (= oldtag16 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr16) 
            )
            (if (= oldtag18 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr18) 
            )
            (if (= oldtag19 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr19) 
            )
            (if (= oldtag20 (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr20) 
            )
           
         (command "_.pspace")
         (COMMAND "ZOOM" "e")
    (PRINC (GETVAR "CTAB"))
    ) ; end foreach
    ) ; end foreach
    
    (SETVAR "REGENMODE" 1)
    
    ) ; end defun ah
    
    (setq curtab (getvar "Ctab"))
    
    (vl-load-com)
    (ah:sheetupdate1)
    
    
    (setvar "ctab" curtab)
    (princ)

Similar Threads

  1. Flipping Text Attributes
    By bap020799 in forum Dynamic Blocks - Technical
    Replies: 7
    Last Post: 2013-07-11, 12:38 PM
  2. Text Mask for Attributes
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 13
    Last Post: 2009-09-08, 09:16 PM
  3. Text or Attributes
    By ablanchard in forum AutoCAD Customization
    Replies: 3
    Last Post: 2008-01-19, 07:37 PM
  4. Text or Attributes to Not Rotate in DB's
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2008-01-10, 05:47 PM
  5. Better text control within attributes
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2006-02-13, 01:08 PM

Tags for this Thread

Posting Permissions

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