+ Reply to Thread
Page 4 of 4 FirstFirst ... 2 3 4
Results 31 to 34 of 34
  1. #31
    Junior Member
    Computer Details
    JGupte's Computer Details
    Operating System:
    Windows 7
    Discipline
    Construction
    JGupte's Discipline Details
    Occupation
    Document Controller/Report Writer
    Discipline
    Construction
    Using
    AutoCAD 2016
    Join Date
    Aug 2017
    Location
    Sydney, Australia
    Posts
    15

    Default

    Registered forum members do not see this ad.

    Hi BIGAL, and thanks for your replies.

    Firstly, at the beginning, I did not have any EXCEL code. I was trying to create it and looking for ideas. In parallel to this forum thread I have been experimenting with various functions to find the best suitable to my purpose.

    We actually have quite a few drawings with multiple sheets, and multiple drawings, each for a different aspect of the project.

    As a start I was working with a single page drawing, but came to realise that was not the best way to start as I would encounter problems when I moved to multi-page drawings. I have now switched to multi-page drawings.
    I am not a draftsman, and this is my first exposure to AutoCAD. am a Document Controller, with some experience with Excel Macros, which is why I have been asked to work this out.

    All our drawings come from the same template (for title block) so have the same attributes.

    I have figured out that the GATTE function is what I need to update multiple title blocks in one drawing with the same attribute names.

    I just can't get ti to work. It does not recognise the attribute names, even though they are in the list that GATTE returns.

    JG

  2. #32
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,815

    Default

    I think your still going down the wrong path its probably simpler to go directly to the tag name and update using a lisp or VBA. You should be able to drive from excel but I would still recommend doing updates in Autocad and updating the excel.

    Here is one example of updating attributes. Others have plenty also. You should also look at www.lee-mac.com for his global block attribute update code, you may be able to drive that from the command line.

    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 )
    
    (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 EAST PORTARLINGTON")
    
    (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 EAST PORTARLINGTON")
    
    (setq oldtag16 "SUBURB") ;attribute tag name
    (setq newstr16 "ROAD SEALING")
    
    (setq oldtag18 "DESIGNER") ;attribute tag name
    (setq newstr18 "BIGAL")
    
    (setq oldtag19 "DRAFTER") ;attribute tag name
    (setq newstr19 "BIGAL")
    
    (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)
    This is a direct method example error checking has been removed.
    Code:
    (setq obj (vlax-ename->vla-object (car (entsel "Select Block"))))
    (setq att (vlax-invoke obj 'getattributes))
    
    (vla-put-textstring (nth 0 att) atlength)
    (vla-put-textstring (nth 1 att) atdesc)
    (vla-put-textstring (nth 2 att) att1)
    (vla-put-textstring (nth 3 att) att2)
    A man who never made mistakes never made anything

  3. #33
    Junior Member
    Computer Details
    JGupte's Computer Details
    Operating System:
    Windows 7
    Discipline
    Construction
    JGupte's Discipline Details
    Occupation
    Document Controller/Report Writer
    Discipline
    Construction
    Using
    AutoCAD 2016
    Join Date
    Aug 2017
    Location
    Sydney, Australia
    Posts
    15

    Default

    If I drive this from AutoCAD, then I have to open each of the 2000 AutoCAD drawing files and run the script to import the Attribute values.
    If I drive it from Excel, then I only open one Excel file, and the procedure will then open and update each AutoCAD drawing file listed in sequence - or am I missing something?

    As stated before, I don't really care what the current value of the Attribute is. I just want to change it to a known value as listed in the Excel file.

    From what I can see, it will be a bit faster to get the values from the Excel row, then open the AC dwg, change attribute values globally (where more than 1 page) and close the sheet.

    The alternative is to create some sort of batch file that will open each AC dwg, and the Excel file, search the excel file for document no, then import the Attribute values.

    Again, I am more experienced using Excel than AutoCAD and LISP, so it will take me longer to go the second method (assuming the batch file will be in Lisp).

    Thanks for the link to www.lee-mac.com. Unfortunately, as I don't know LISP (and have no time to learn), those routines are not much use to me.

  4. #34
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,815

    Default

    Registered forum members do not see this ad.

    The answer youwill be looking for is the Ctab variable for multiple layouts a blank dwg will have ctab set to either "Model" or "Layout1" you can use this to set your layout names then update that sheet with the correct attributes. See code supplied this is the same in VBA you could use VBA send "CTAB" your layout name.
    A man who never made mistakes never made anything

Similar Threads

  1. Insert a title Block from excel into a opened dwt with excel vba
    By alex140590 in forum .NET, ObjectARX & VBA
    Replies: 2
    Last Post: 15th Jul 2016, 11:43 am
  2. Replies: 9
    Last Post: 19th Apr 2016, 03:43 pm
  3. Title block to excel spreadsheet
    By keiths in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 3rd Dec 2013, 07:26 am
  4. Excel spreadsheet to update autocad drawing title block
    By Jasenc in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 11th Feb 2013, 12:47 pm
  5. EXCEL Drawing register using Autocad Title Block Attributes
    By SimonC in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 25th Aug 2010, 03:40 am

Bookmarks

Posting Permissions

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