AutoCAD.Net/C#.Net QQ群:193522571 从已有cuix中导入工作经典空间

[CommandMethod("cloneWS")]public void cloneWorkSpace(){ try { string sourceCuiFileName = @"C:\TEST.CUIX"; if (!File.Exists(sourceCuiFileName)) return; string curCuiFileName = Application.GetSystemVariable("MENUNAME").ToString() + ".cuix"; CustomizationSection curCui = new CustomizationSection(curCuiFileName); CustomizationSection sourceCui = new CustomizationSection(sourceCuiFileName); string workspaceName = "test1"; WorkspaceCollection curWorkspaces = curCui.Workspaces; int curWsIdx = curWorkspaces.IndexOfWorkspaceName(workspaceName); // test1 already exists, so just return // cloning overwrites the existing Workspace if (curWsIdx != -1) return; Workspace newWs = sourceCui.getWorkspace(workspaceName); ContainerCloneAction containerClnAction = new ContainerCloneAction(); Workspace ws = curWorkspaces[0]; curWorkspaces.Clone(newWs, ws, ref containerClnAction); if (curCui.IsModified) { curCui.Save(); } } catch (Autodesk.AutoCAD.Runtime.Exception e) { Application.ShowAlertDialog("AutoCAD exception:\n" + e.Message); return; }}

 

相关文章