Monday, September 24, 2007

Run a script when changing workspace in AutoCAD

Did you know that you can run a script (.SCR) file automatically when changing workspace in AutoCAD?

Using the Customize User Interface (CUI) it's not possible. You can only specify LISP files to be loaded together with the customization file.

But here is how it can be done. It's undocumented (and probably not supported) but can still be very useful. And with the script file you can also load AutoLISP (.LSP) files when the workspace changes. It is supposed to work with AutoCAD 2007 and I have confirmed it works in AutoCAD 2008. Verticals should also work. Notice that the script is not run when you start AutoCAD. Only when the workspace is changed. But it is not run if it is changed using AutoLISP like this: (command "WSCURRENT" "2D Drafting & Annotation")

Locate the CUI file you want to change. For example:
C:\Users\JTB\AppData\Roaming\Autodesk\AutoCAD 2008\R17.1\enu\support\acad.cui

If you have hard to locate the CUI file you can just run the CUI command and you will find the file path and name.

Using XML Notepad 2007 locate the Workspace that you want. The UID has the name. In this case WS_Anno2DDraft.


Right click on UID and select Attribute>After and enter Script and then enter the script file to be loaded.


Or you can edit using Notepad or the like. Search for "<Workspace ". Notice the space after Workspace and don't include the quotation marks. Then add what is marked as bold below changing the path and name of course.

<Workspace StartOn="ignore" ScrollBars="ignore" ScreenMenus="off" LayoutModelTabs="ignore" DefaultWorkspace="true" UID="WS_Anno2DDraft" Script="C:\Users\JTB\AppData\Roaming\Autodesk\AutoCAD 2008\R17.1\enu\Support\test.scr">

Thanks for the tip Chris Dodge,

Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner