I create a panel with one button,when I click the button,it will call a command to create a layer and linetype, but autocad always prompt me a "eLockViolation" error.
If I do not use panel,the code create layers and linetype correctly.
public class Command
{
static PaletteSet palette;
static bool wasVisible;
/// <summary>
/// Creates the palette if it did not already exist, and shwos it.
/// </summary>
[CommandMethod("test" )]
public static void CreateGridPanel()
{
if (palette == null)
{
palette = new PaletteSet("CaiGrid", "CONVPALETTE", new Guid("{929CAC46-8606-4580-A953-238B70CA76A1}"));
palette.Style =
PaletteSetStyles.ShowAutoHideButton |
PaletteSetStyles.ShowCloseButton |
PaletteSetStyles.ShowPropertiesMenu;
palette.MinimumSize = new System.Drawing.Size(410, 240);
palette.AddVisual("CaiGrid", new GridView());
// Automatically hides the palette while there is no active document.
var docs = Application.DocumentManager;
docs.DocumentBecameCurrent += (s, e) => palette.Visible = e.Document == null ? false : wasVisible;
docs.DocumentCreated += (s, e) => palette.Visible = wasVisible;
docs.DocumentToBeDeactivated += (s, e) => wasVisible = palette.Visible;
docs.DocumentToBeDestroyed += (s, e) =>
{
wasVisible = palette.Visible;
if (docs.Count == 1)
palette.Visible = false;
};
}
palette.Visible = true;
}
}