码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2019-10-14 10:22:05      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:modified   auto   des   mod   ons   indexof   rcu   show   uname   

[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;
    }
}

 

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

标签:modified   auto   des   mod   ons   indexof   rcu   show   uname   

原文地址:https://www.cnblogs.com/swtool/p/11669773.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!