Introduction to AutoCAD Scripts
Hi Everyone,
Here I am to bother you and kill (/ save) your time again.
Hope you are all enjoying the blog.
Today, We will talk about AutoCAD scripts.
Before explaining what scripts are. First, let's see why they are needed.
If you have any action that you repeat multiple time. You should think about automating it, so you don't have to go to the same steps over & over again.
The easiest way to do this within AutoCAD is to write a script.
So, What is a Script to AutoCAD?
To AutoCAD a script is an ASCII text file that contains a set of commands for AutoCAD to follow.
Characteristics of a script file :
The path should look something like this
c:\Program Files\Autocad 2010\acad.exe /b script_name
Click Ok & You are done.
Now open your AutoCAD using this shortcut.
Everytime you open AutoCAD using this shortcut the script will run itself.
This way you can set up AutoCAD system variables, change your workspace, load/unload menus and lisp files of your choice on the startup.
You may be working on different projects at a time which needs different AutoCAD setup files. By editing your shortcut you can have different shortcuts for different projects.
Sorry for the long post guys, but I could not avoid.
Next time I will come up with an example of scripting.
Try this and let me know your achievements.....and problems if any.
Thanking You,
Abhay Chauhan
Hi Everyone,
Here I am to bother you and kill (/ save) your time again.
Hope you are all enjoying the blog.
Today, We will talk about AutoCAD scripts.
Before explaining what scripts are. First, let's see why they are needed.
If you have any action that you repeat multiple time. You should think about automating it, so you don't have to go to the same steps over & over again.
The easiest way to do this within AutoCAD is to write a script.
So, What is a Script to AutoCAD?
To AutoCAD a script is an ASCII text file that contains a set of commands for AutoCAD to follow.
Characteristics of a script file :
- Scripts are text files.Usually created with notepad.
- They have an SCR file name extension, So make sure you save them like that.
- Scripts use only command line syntax.
- Scripts can not access dialog boxes, toolbars etc.
Now, How to write a script file?
Follow these simple steps
- Run through the steps that you want to automate, using the command line. Use "-" before the command to suppress the dialog boxes.
- Now, press F2 to access your command line and copy the content from your command window.
- Paste it into notepad.
- Press enter at the end of each command, this is equivalent of pressing Enter at command line. While running the script AutoCAD reads each space as an Enter. So be careful, you need to be exactly right!. It is suggested to keep every command on a separate line.
- Enclose any layer names, file names, paths that contain spaces in "quotations".
- Insert comments if you wish so to make the script understandable and more presentable. To start a comment start the line with a semicolon.
- Save the text file with an SCR extension.
To run a script use "SCRIPT" command, select your script file and open.
There may be requirement of running a script file each time you open AutoCAD. you can do so using your AutoCAD shortcut on your desktop.
To do this,
There may be requirement of running a script file each time you open AutoCAD. you can do so using your AutoCAD shortcut on your desktop.
To do this,
- Right click the shortcut and choose properties.
- Click the shortcut tab. You will see the path of your acad.exe file, at the end of this add a space and then the following
/b script_name
The path should look something like this
c:\Program Files\Autocad 2010\acad.exe /b script_name
Click Ok & You are done.
Now open your AutoCAD using this shortcut.
Everytime you open AutoCAD using this shortcut the script will run itself.
This way you can set up AutoCAD system variables, change your workspace, load/unload menus and lisp files of your choice on the startup.
You may be working on different projects at a time which needs different AutoCAD setup files. By editing your shortcut you can have different shortcuts for different projects.
Sorry for the long post guys, but I could not avoid.
Next time I will come up with an example of scripting.
Try this and let me know your achievements.....and problems if any.
Thanking You,
Abhay Chauhan
I like the idea of a script file. I do the same using Excel to create the script for me and then just right click in the command line and select paste. Rather than change the FILEDIA system variable to 0, I use a hyphen (-) to suppress dialog boxes. An example would be the BLOCK command which will bring up a dialog box. Try -BLOCK and no dialog box will show.
ReplyDeleteTony,
ReplyDeleteThankyou for your feedback. I will soon revise the post to incorporate your suggestion.
Keep visiting.