public void layerchangedmonitor()
{
acApp
.SystemVariableChanged += new Autodesk
.AutoCAD.ApplicationServices.SystemVariableChangedEventHandler(SysVariableChange
); }
void SysVariableChange(object sender, Autodesk.AutoCAD.ApplicationServices.SystemVariableChangedEventArgs e)
{
if (e.Name == "CLAYER")
{
//do anything you want here. I got the current layer then updated a text box with its name and another with the color that matched its values.
string currentWorkspaceName = (string)acApp.GetSystemVariable(e.Name);
LayerTableRecord mylayer = MyCollectors.GetCurrentLayer();
CurrentLayerBox.Text = mylayer.Name.ToString();
CurrentLayerColorBox.BackColor = mylayer.Color.ColorValue;
}
}