首页 > 代码库 > 双击 cui

双击 cui

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//改变属性块的双击事件
//将菜单文件中的双击改一下,退出时还原文件 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;
        }
    }
}