雙擊 cui

         //改變屬性塊的雙擊事件
        //將菜單文件中的雙擊改一下,退出時還原文件 acad.bak.cui 改這個名字 每次用這個更新爲新的 acad.cui進行修改
        //退出時再用 acad.bak.cui還原acad.cui
        public static void ChangeCuiForDoubleChick(string cmd)
        {
            string cuiPath =
            @"C:\Documents and Settings\Administrator\Application Data\Autodesk\AutoCAD 2007\R17.0\chs\Support\acad.cui";
            Autodesk.AutoCAD.Customization.CustomizationSection cs = new CustomizationSection(cuiPath, "ACAD"); ;

            string mgName = "HoulinboMenuGroups";//宏組
            string mmName = "HoulinboDblblockMacro";//宏
            string command = cmd; //對應屬性塊編輯查看宏命令 
            string dblclickEID = "ID_VFHoulinboForDoubleChick";

            //菜單宏
            MenuMacro oMenuMacro1 = cs.FindMenuMacro(mmName);
            if (oMenuMacro1 == null)
            {
                //先自定義宏組
                MacroGroup oMacroGroup = cs.MenuGroup.FindMacroGroup(mgName);
                if (oMacroGroup == null)
                    oMacroGroup = new MacroGroup(mgName, cs.MenuGroup);
                oMenuMacro1 = new MenuMacro(oMacroGroup, mmName, command, dblclickEID, MacroType.Any);
            }
            foreach (DoubleClickAction dc in cs.MenuGroup.DoubleClickActions)
            {
                if (dc.DxfName.Equals("ATTBLOCKREF"))
                {
                    dc.DoubleClickCmd.MacroID = dblclickEID;
                    cs.SaveAs(cuiPath);
                    return;
                }
            }
        }
相關文章
相關標籤/搜索