Jump to content

Macro to automate filling in title Blocks


jrobdesign

Recommended Posts

Hi everyone,

 

I am in a situation where I need to input an initial and a date into a "checked by/ approved by" column contained inside a title block, and there is over 300 drawings I need to do this to.

 

Is there a way to automate this task by using a macro or a script? I have done a bit of investigation of macros and I have worked out how to set basic drawing commands like drawing a line or a circle, however I cant find info anywhere on how to automate the filling in of properties within a title block? Is it even possible, or do I have to open all 300+ drawings and change properties manually?

 

Let me just say that I am not an experienced AutoCAD user, as I normally work with Inventor, but Need to supply a customer with AutoCAD drawingsfor a project.

 

If anyone could help or point me in the right direction I would be most appreciative.

 

Thanks!

Link to comment
Share on other sites

Welcome to CADTutor forum. :)

 

Check out

 

http://www.lee-mac.com/batte.html

Stands for Batch Attribute Editor.

 

http://www.lee-mac.com/bfind.html

This would be used to change any existing values or text to defined new values

in the same way, in a heart beat. Just like the TEXT FIND & REPLACE used in Windows, but it will go into attributes, blocks and all sorts of other things.

Very powerful and generous of Lee to make these available to the community, free of charge.

 

You will be glad you did.

If you have never used LISP, check on Lee's Home page and he will talk you through how to do it.

Using one of Lee's lisps 300 drawings could be done in less than a minute without the need to open any of the drawings.

Read the instructions carefully.

 

Thanks Lee! :beer:

Link to comment
Share on other sites

2 methods.

 

Using lisp you can change a blocks attributes pretty easy, to do 300 drawings you would use a script that opens the dwg runs the lisp and closes again repeat 300 times. You will be suprised depending on the dwgs this task will occur pretty quick.

 

Other method is using .Net or similar program you can change a dwg without opening I can not help here.

 

Here is a script to change a attribute for all layouts to "Issued". A better version the lisp needs a slight mod and could be loaded once as part of startup.

 

Open dwg1 (load "issued") close Y
Open dwg2 (load "issued") close Y
Open dwg3 (load "issued") close Y
[code]

[code]
; changes to issued for construction
: thanks to lee mac for original code
(vl-load-com)
; 1.  Get current date in mm/dd/yy format.
(defun ddmmyy (/ x today)
    (setvar "cmdecho" 0)
    (setq x (getvar "CDATE"))                 ; get current date
    (setq today ( rtos x 2 4))                    ; convert to a string
    (setq date (strcat (substr today 7 2) "."    (substr today 5 2) "." (substr today 3 2) ))
)

(setq oldtag1 "DRAWING_STATUS") ;attribute tag name
(setq newstr1 "ISSUED FOR CONSTRUCTION")
(setq oldtag2 "REV_NO")  ;attribute tag name
(setq newstr2 "0")
(setq ss1 (ssget "x"  '((0 . "INSERT") (2 . "DA1DRTXT"))))
(setq inc (sslength ss1))
(repeat inc      
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (setq inc (1- inc)) )) '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
) ; end for
) ;end repeat
(setq oldtag1 "REV-NO")
(setq newstr1 "0")
(ddmmyy)
(setq oldtag2 "DATE")
(setq newstr2 date)
(setq oldtag3 "AMENDMENT")
(setq newstr3 "ISSUED FOR CONSTRUCTION")
(setq ss2 (ssget "x"  '((0 . "INSERT") (2 . "REVTABLE"))))
(setq inc (sslength ss2))
(repeat inc
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname ss2 (setq inc (1- inc)))) 'getattributes)
(if (= oldtag1 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr1) 
)
(if (= oldtag2 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr2) 
)
(if (= oldtag3 (strcase (vla-get-tagstring att)))
(vla-put-textstring att newstr3) 
)
)
)
(setq ss1 nil)
; (setq ss2 nil)
(princ)

Link to comment
Share on other sites

Thanks guys for your help. I have downloaded and installed lee macs Batch Attribute Editor but I cant seem to get it to run inside Autocad. I ran the installer but it didnt geve me any options for where to install etc, it jus ran automatically. Now when I type BATTE in the command line I get an error message saying "Unkown command"

Link to comment
Share on other sites

Thanks guys for your help. I have downloaded and installed lee macs Batch Attribute Editor but I cant seem to get it to run inside Autocad. I ran the installer but it didnt geve me any options for where to install etc, it jus ran automatically. Now when I type BATTE in the command line I get an error message saying "Unkown command"

 

Did you LOAD it?

If not type APPLOAD at the commandline, and you will be taken to the dialog box where you can select and load it, you may choose to add it to your STARTUP SUITE, so that it is always available, maybe not.

Once you have done that it should work.

 

As you start to understand and become comfortable with lisps, you will most likely put those, upon which you rely, in your Startup Suite.

 

I am assuming that you selected the DOWNLOAD option on Lee's site?

You need to pay attention to the download destination, perhaps start a new folder named LISPS for future use.

appload dialog box.JPG

Link to comment
Share on other sites

Like Dadgad if you are going to do lots of lisps etc make a directory and put them all in one location. Do CONFIG, FILES, Support File Search path, add your directory this way you can do direct loads as simple as typing (load "batte")

Link to comment
Share on other sites

I have downloaded the installer, which has saved into my Downloads folder.

 

When I run the installer it doesn't give me an option to see or choose where it is being installed, so when I go to load from Autocad (Load/unload applications - as shown above) i can't find the destination of the file to load?

 

I also have no idea what the name of the file is i am looking for?

Link to comment
Share on other sites

I have downloaded the installer, which has saved into my Downloads folder.

 

When I run the installer it doesn't give me an option to see or choose where it is being installed, so when I go to load from Autocad (Load/unload applications - as shown above) i can't find the destination of the file to load?

 

I also have no idea what the name of the file is i am looking for?

 

You should be downloading by clicking on the highlighted link in the screenshot from Lee Mac's awesome website, not installing.

That means that you are saving the highlighted .lsp file (that is the name you are looking for) onto your computer, so that you can later access it, from within Autocad.

 

If you can find the .lsp file in your download folder, start a new folder somewhere other than in your download folder, give it a name that makes sense to you, so you will remember it,

and move the .lsp file into it.

 

Then revisit posts # 5 & 6.

Once you have successfully loaded the .lsp file, you will start it at the commandline, by typing BATTE , then

you are off to the races. I hope you took my earlier suggestion to read Lee's instructions for using a lisp.

You can do it & will love it, hang in there. :shock:

The considerable time you save, will be your own. :)

BATTE download shot.jpg

Link to comment
Share on other sites

For what it is worth, I have used a batch file to create a loop that opens each drawing in a specified folder and runs a script that chanfes the attributes I wanted. It was for a situation similar to what I understand the OP's to be. No lisp or third party required.

 

Batch file looked like this:

FOR %%f in (Z:\TEST\*.dwg) do start /wait C:\"Program Files"\"Autodesk"\"AutoCAD LT 2011"\acadlt.exe "%%f" /b Z:\TEST\ATTCHANGE.scr

 

Script looked like this:

FILEDIA
0
-ATTEDIT
N
N
*
*
*
20021379
20021382
FILEDIA
1
QSAVE
QUIT
Y

 

It went on to also create a PDF, and plot a hardcopy of each as it opened them.

 

I had to save the .bat file and the .scr file in the same folder as I was editing, and then use Windows to call the .bat which called the .scr

Link to comment
Share on other sites

I use GATTE in a script.

example:

 

GATTE

BLOCK

"blockname"

NAME

"attributte tag"

%%

YES

 

And you can use Scriptpro to run on multiple drawings.

 

Note: if the drawing contains more layouts/tabs, every tittle block is changed.

 

 

PmxCAD

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...