Automating Revision Number Updates in Multiple Drawings

Automating Revision Number Updates in Multiple Drawings

nuwul
Advocate Advocate
161 Views
12 Replies
Message 1 of 13

Automating Revision Number Updates in Multiple Drawings

nuwul
Advocate
Advocate

Hi, does anyone know how to change the text in a title block and attribute block across multiple drawings at the same time? I have hundreds of drawings that need the revision number updated. Is there any quick method or LISP routine that can help automate this? I don’t know how to build my own LISP, so any help would be greatly appreciated.

 
0 Likes
162 Views
12 Replies
Replies (12)
Message 2 of 13

Moshe-A
Mentor
Mentor

@nuwul hi,

 

You might get more quick help if you post this >> here << 

 

Moshe

 

Message 3 of 13

Moshe-A
Mentor
Mentor

@nuwul  hi,

 

post sample dwg with the title block.

 

Moshe

0 Likes
Message 4 of 13

a.zwegers
Contributor
Contributor
( defun Revision ( / SUMM REV )
( setq SUMM ( vla-get-summaryinfo ( vla-get-activedocument ( vlax-get-acad-object ) ) ) )
( setq REV ( vla-get-revisionnumber SUMM ) )
( if ( or ( = REV "" ) ( = REV " " ) ( = REV nil ) )
	( vla-put-revisionnumber SUMM "0" )
	( vla-put-revisionnumber SUMM ( itoa ( + ( atoi REV ) 1 ) ) )
)
( princ )
)

 ups the revision number every time you run it using (Revision), from nil to 0 to 1 to 2 etc.

But yes, this should be moved to the Lisp Forum 

0 Likes
Message 5 of 13

nuwul
Advocate
Advocate

Hi, This is one of the drawing. i have hundred of this, and i just want to change the revision number in the titleblock

0 Likes
Message 6 of 13

nuwul
Advocate
Advocate

how to use this after LOAD? 
does this apply to multiple drawings?

0 Likes
Message 7 of 13

a.zwegers
Contributor
Contributor

"You run it using (Revision)".

Needs to be loaded and run per drawing (use a batch script for that). If you are not entirely sure how to apply such or work with Lisp, actually I would recommend not doing this (yourself).

Batch processing large amount of drawings can do quite a bit of damage when anything goes wrong and will take quite bit of time too. (in principle AutoCAD will load and open each file, apply your script, save and close the drawing)

0 Likes
Message 8 of 13

a.zwegers
Contributor
Contributor

Seen the amount of time any of this would take compared to any real use of the revision number - you may seriously ask yourself if it's worth doing. (besides risks run when using potentially dodgy batch scripts)

0 Likes
Message 9 of 13

komondormrex
Mentor
Mentor

hey, 

check the following. autocad, autolisp bound. 

(vl-catch-all-apply 'acet-load-expresstools)
(defun c:mass_change_rev_number (/ acad_dbx_object work_directory rev_att rev_number)
  (setq rev_number (itoa (getint "\nEnter revision number to change to: ")))
  (setq acad_dbx_object (vlax-create-object (strcat "objectdbx.axdbdocument." (substr (getvar 'acadver) 1 2))))
  (setq work_directory (strcat (acet-ui-pickdir "Pick directory to process" "c:\\") "\\"))
  (foreach dwg_file (vl-directory-files work_directory "*.dwg" 1)
    (if (null (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list acad_dbx_object (strcat work_directory dwg_file)))))
      (progn
        (setq rev_att nil)
        (vlax-map-collection (vla-get-modelspace acad_dbx_object)
            '(lambda (object) (if (and (= "AcDbBlockReference" (vla-get-objectname object))
                           (= "Title Block" (vla-get-effectivename object))
                        )
                        (if (vl-some '(lambda (att) (= "REV" (vla-get-tagstring (setq rev_att att))))
                                  (vlax-invoke object 'getattributes)
                            )
                              (if (/= (vla-get-textstring rev_att) rev_number)
                            (progn
                                  (vla-put-textstring rev_att rev_number)
                                  (princ (strcat "\nFile: \""
                                       dwg_file
                                       "\", attribute tagged \"REV\" in block \"Title Block\" changed value to \""
                                       rev_number
                                       "\""
                                   )
                              )
                                (vla-saveas acad_dbx_object (strcat work_directory dwg_file))
                            )
                                (princ (strcat "\nFile: \""
                                     dwg_file
                                     "\", attribute tagged \"REV\" in block \"Title Block\" has already value of \""
                                     rev_number
                                     "\""
                                 )
                            )
                           )
                        )
                      )
             )
        )
        (if (null rev_att)
            (princ (strcat "\nFile: \""
                    dwg_file
                     "\", block \"Title Block\" not found in modelspace or attribute \"REV\" not exist in block"
                 )
              )
        )
      )
      (princ (strcat "\nFile: \"" dwg_file "\" - can't open!"))
      )
  )
  (vlax-release-object acad_dbx_object)
  (princ)
)

 

0 Likes
Message 10 of 13

paullimapa
Mentor
Mentor

Could you share a couple of sample dwgs and show us exactly which block attribute that needs the value changed?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 11 of 13

paullimapa
Mentor
Mentor
0 Likes
Message 12 of 13

paullimapa
Mentor
Mentor
0 Likes
Message 13 of 13

dvblue88
Observer
Observer

@nuwul 

If your drawings are connected to a Sheet Set Manager, you can update the revision number for all of them at once. Just open the Sheet Set (.dst file), right-click the sheet set name, go to Properties, and add or change a custom property like "RevisionNumber." In your title block, use a field that links to that property. When you change the value in the Sheet Set, all drawings using that field will update automatically. You might need to use the REGEN or UPDATEFIELD command to refresh the text. It's a clean way to manage revisions without opening each file.

If your drawings aren't connected to a Sheet Set Manager, I also often use a trick: create a text object (in your title block) with a field linked to the drawing properties (dwgprop). Then, you can use a batch tool like batch dwg properties to update the revision number across multiple drawings at once. This method works well for large sets of files.

0 Likes