我用一个按钮创建了一个面板,当我单击该按钮时,它将调用一个命令来创建图层和线型,但autocad总是提示我一个“eLockViolation”错误。
如果我不使用panel,代码将正确创建图层和线型。
- public class Command
- {
- static PaletteSet palette;
- static bool wasVisible;
- ///
- /// Creates the palette if it did not already exist, and shwos it.
- ///
- [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;
- }
- }
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |