Thursday
Autocad, ProgrammingScript Usage (To Edit Multiple Drawings Quickly)
Hi,
I had to edit 300 different blocks at the start of this week. For each drawing, I had to open them one by one, repeat same process again and then save and exit from them. Instead, I wrote a script to ease the process and AutoCAD do the process by itself for me. This allows me work on other drawings and it is like I didn’t do anything wrong at all. When I was working on my script, I remember you, dear bloggers, and wish to share it with you.
Like us, most of you probably have block libraries and drawing files of your own. One day if you have to edit a block through all of these drawings, this boring work costs a lot of time and also a lot of work. Moreover, opening a document and doing same processes again and again makes you careless and thus; you will probably start to make mistakes. Let me start to explain how to write and use scripts.
Firstly, we have to list the drawings that we want to edit. The list should contain drawing names each on a different line and should be listed downwards. You can think that, it can take very long time, ‘These scripts are supposed to fasten my drawing time’ etc. however; forming the list is very easy. Open ‘Run’ from Start Menu (Windows Operating System) and type “cmd” for DOS screen. Follow the steps below.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\orhan>cd \myDrawings
C:\myDrawings>dir *.dwg /b > list.txt
C:\myDrawings>_
The “dir *.dwg /b > list.txt” command will create the LIST.TXT file containing the drawing (DWG) files list. We’ll use MS-Word to convert our TXT file to AutoCAD SCR file.

Fig.1 Our TXT file

Fig.2 AutoCAD script file
You do not have to arrange the list by your hand; you can utilize a word macro. Open the list in MS Word and with using the macro; names of the drawings become; Open ‘Drawing Name’ and they are followed by the commands we want to run. You can download our sample from here.

Fig.3 – Our MS Word Macro
Run this macro in MS Word and save your file as TEXT. Don’t forget to name your file as SCR (e.g. “convert.scr”)
Before running the script, we are going to change one last thing. We have to define the directory that contains drawings as Support file search path since script contains only the drawing names. To do this, add the folder that contains the drawings into the Support file search path in the “tools->options” menu file tab in Autocad.

Figure 4
We can run the script now. Click the “Run Script” in the “tools” menu and select the script file. Autocad will do the rest. You can use lisp files with scripts to do more complicated editing.
Regards.
Related Files:
- script.zip (contains MS Word and VB Class files)
Technorati Tags: AutoCAD, script usage, Daily AutoCAD
Viewed 8,809 times so far... This week: 109 Today: 5 Latest: 4 July 2009, 22:59Post Tags:
Related Posts
Popular
- Hip tip: Increasing view resolution with VIEWRES system variable
07/03/2009 04:39 am
7 Comments - Sirince – IZMIR
07/02/2009 11:02 am
1 Comment - Visual LISP: Programming user interfaces with OpenDCL
07/01/2009 10:15 pm
10 Comments - 3D Modeling 7: EXTRUDE
06/30/2009 02:14 pm
10 Comments - Ask DailyAutoCAD: Which Notebook to Buy?
06/30/2009 12:17 pm
1 Comment
Featured Articles
- AutoCAD 2009 Update 3 Released
- Speed Up As AutoCAD 2009 Ribbon Menu Helps You!
- MEP Analysis Extension for AutoCAD MEP extended to March 31, 2009
- Recap of AutoCAD-related technologies on Autodesk Labs
- Technology Preview of MEP Analysis Extension extended to 12/31/08
- Autodesk Labs: Forward and Backward utility for AutoCAD
|

Feb 14, 2008
Reply
Dear Mr. Pala,
I am trying to draw an elliptical gear (in 2D) I made the ellipse in x and y axes and even I draw a teeth also to
make it as Polar Array. So, the remaining tooth will be inscribed inside the ellipse. But I don’t have the option to select the ellipse to make array of tooth inscribed inside an ellipse. Could you please advice me how to make an elliptical spur gear in Autocad 2008? Thanks in advance.
Feb 15, 2008
Reply
Thank you for sharing your autocad script. However, the link to script.zip does not work for me.
Feb 28, 2008
Reply
Is it possible to send me your e-mail addres?
I think that I have a more simple and faster methode to writing script files. Exuse me my english. I am dutch speaking.
My methode is to working with Excel 5inside a macro.
Everiting is in dutch, but it works very easely.
Greetings,
Pieter
Mar 3, 2008
Reply
I think, It’s better to make MACRO with AutoCAD VBA instead of MS word.
Apr 9, 2008
Reply
Hello Mr. Pala,
Sir,
I want to make pdf of a 100 dwg files from a local machin folder. These drg nos are listed in a excel sheet in the same folder. The drg nos are random( not like A001, A002,A003…….). All these drgs are of A4 size(297,210). I have to this acivity without opening the cad file. Do you have any script for this.
Jul 29, 2008
Reply
Hello mister Pieter.
It would be very gentle of you if you show us the way that you speak of.
Thanks in advance.
Jul 29, 2008
Reply
Hola.
I have a another cuestion, Is there anyway to change the Length of 3d blocks in an automatizided wayLinking the scripts to the macros of excel?
Jul 30, 2008
Reply
I need to know how to export attribute values from a titleblock to an excel spreadsheet where I can edit them and them import them back to the autoCad file where they will be updated.
Can anyone help me with the code?
Oct 31, 2008
Reply
I HAVE LOTS OF TEXT TO EDIT.. ITS A SINGLE TEXT. HOW CAN I EDIT FASTER? COZ FOR NOW IM DOING 1 BY 1 CLICK JUST TO EDIT THE BUNCH OF SINGLE TEXT…IM USING 2009 AUTOCAD… ANY COMMAND THAT I CAN DO MULTIPLE TEXT EDIT? CAN YOU HELP ME?
Dec 23, 2008
Reply
2009 has a find and replace tool for text. ^f – and follow the prompts.
Jun 9, 2009
Reply
I would really love to use your script, however the link to download it is not working. Can you send it to me via e-mail or let me know how I could get it? I am affraid if I try to copy it off the image I may mess it up and render it useless.