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,


  1. Restored comment
    by Anonymous
    It is a great tip but unfortunately it is not working for me. I did everything as said using XML Notepad 2007 and reload the file to make it sure it is saved and was ok, when I change the WS nothing was happening so I checked the file and found the script was empty, I mean the path and file name was washed out showing blank. I tried many times and heppens the same. please help me where I am doing wrong.

    I have read write access the place I am putting my CUI and script file

  2. Restored comment
    by JTB World
    Did you have AutoCAD closed when editing the XML file?
    What AutoCAD version/flavor?

  3. Restored comment
    by Anonymous
    I tried in both ways Autocad closed and open and no result.
    Civil 3D 2008 with SP1
    XP SP2
    P4 3 GHZ
    3 GB RAM
    256MB VGA


Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner

Contact Us | About JTB World | Subscribe to this blog
JTB World's website | Website General Terms of Use | Privacy Policy
^ Top of page

© 2004- JTB World. All rights reserved.