Script Usage (To Edit Multiple Drawings Quickly)



Author Eren Pala
Profession Mechanical Engineer
  AutoCAD Specialist
Location Istanbul, TURKEY
e-mail  

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
Fig.1 Our TXT file

Fig.2
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
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.

Fig.4
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: , ,

Similar Posts

Rate this article:

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

8 Responses to “Script Usage (To Edit Multiple Drawings Quickly)

  • 1
    Mansur
    February 14th, 2008 14:06

    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.

  • 2
    Phil
    February 15th, 2008 08:56

    Thank you for sharing your autocad script. However, the link to script.zip does not work for me.

  • 3
    Pieter
    February 28th, 2008 11:45

    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

  • 4
    David
    March 3rd, 2008 15:38

    I think, It’s better to make MACRO with AutoCAD VBA instead of MS word.

  • 5
    K Dinesh
    April 9th, 2008 15:52

    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.

  • 6
    Javier
    July 29th, 2008 04:11

    Hello mister Pieter.

    It would be very gentle of you if you show us the way that you speak of.

    Thanks in advance.

  • 7
    Javier
    July 29th, 2008 04:28

    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?

  • 8
    Zaibaa Ali
    July 30th, 2008 13:52

    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?

Leave a Reply