Editor's Note: In July 2010, this tip was updated with a new ZIP file that corrects a mistake and includes updates to the DLL and source code files.
Repeat contributor Andy Maser has submitted the first .NET tip to Cadalyst's CAD Tips library! This routine adds an event handler that will apply a layer state with the same name as the layout each time you switch layouts. If no matching layer state is found, however, then no action is taken. For example, if you switch to a layout named "SITEPLAN," and a layer state named "SITEPLAN" exists, then it will be applied to this layout. .NET routines are compiled to a DLL file, which can be loaded using the NetLoad command. However, Andy has provided a LISP file to load the .NET routine and start the event handler. All you have to do is edit the LISP file and change the path to the DLL file. Andy's source code is also included.