By Adam Nagy
If you need to monitor the workspace change, e.g. so that you can update the Ribbon with the controls you placed using the Ribbon Runtime API, then you can listen to the system variable changed event, and watch out for WSCURRENT
using System;
using Autodesk.AutoCAD.Runtime;
using acApp = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.ApplicationServices;
[assembly:CommandClass(typeof(TestProject.Commands))]
namespace TestProject
{
public class Commands
{
[CommandMethod("MonitorWorkspaceChange")]
public void MonitorWorkspaceChange()
{
acApp.SystemVariableChanged +=
new SystemVariableChangedEventHandler(
acApp_SystemVariableChanged);
}
void acApp_SystemVariableChanged(
object sender, SystemVariableChangedEventArgs e)
{
if (e.Name == "WSCURRENT")
{
string currentWorkspaceName =
(string)acApp.GetSystemVariable(e.Name);
// Do whatever you need
}
}
}
}