Managed Objectarx 自定义\双击动作\(双击打开自定义Form)

 

 

Ref: Autocad2008 Help + Objectarx for 2008

1.参考编辑属性命令:eattedit,实现双击属性块执行自定义宏命令ShowDeviceAtt。

 

 

 [CommandMethod("dblclick")]
        
public void doubleClick()
        {
           
string mgName = "mxMenuGroups";//宏组
            string mmName = "DblblockMacro";//
            string command = "ShowDeviceAtt"//对应属性块编辑查看宏命令 
            string dblclickEID = "DCU_myBlockdblclick";
            
//菜单宏
            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, "DblblockMacro", MacroType.Any);
            }
            
foreach (DoubleClickAction dblclick in cs.MenuGroup.DoubleClickActions)
            {
                
if (dblclick.ElementID == dblclickEID)
                {
                    ed.WriteMessage(
"已经添加属性块双击自定义动作");
                    
return;
                }
            }
            DoubleClickAction dblClickAction 
= new DoubleClickAction(cs.MenuGroup, "mxBloc dblclick "-1);//定义双击动作
            dblClickAction.Description = "元件属性编辑查看";//说明
            dblClickAction.ElementID = dblclickEID;//元素ID
            dblClickAction.DxfName = "ATTBLOCKREF";//(双击)对象名称

            DoubleClickCmd dblClickCmd 
= new DoubleClickCmd(dblClickAction);//双击命令
            dblClickCmd.MacroID = oMenuMacro1.ElementID;//宏ID

            dblClickAction.DoubleClickCmd 
= dblClickCmd;
            saveCui();
            ed.WriteMessage(
"属性块双击自定义动作添加成功");

        }

 

2.参考 ObjectARX 2008\samples\dotNet\CuiSamp例子‘修改Polyline双击命令’,即可实现属性块双击自定义

 

[CommandMethod("dblclick")]
public void doubleClick()
{
//自定义宏命令
MacroGroup oMacroGroup = new MacroGroup("mxMenuGroups", cs.MenuGroup);
MenuMacro oMenuMacro1 
= new MenuMacro(oMacroGroup, "DblblockMacro""ShowDeviceAtt""DblblockMacro", MacroType.Any); //ShowDeviceAtt为对应属性块编辑查看宏命令 

DoubleClickAction dblClickAction 
= new DoubleClickAction(cs.MenuGroup, "mxBloc dblclick "-1);//定义双击动作
dblClickAction.Description = "元件属性编辑查看";//说明
dblClickAction.ElementID = "DCU_myBlockdblclick";//元素ID
dblClickAction.DxfName = "ATTBLOCKREF";//(双击)对象名称

DoubleClickCmd dblClickCmd 
= new DoubleClickCmd(dblClickAction);//双击命令
dblClickCmd.MacroID = oMenuMacro1.ElementID;//宏ID

dblClickAction.DoubleClickCmd 
= dblClickCmd;

}

 

说明:执行dblclick、savecui ,只需要第一次使用时注册双击命令即可,适合在安装包中注册与恢复。

测试打开属性块编辑窗口2种方式:
1.双击属性块
2.输入命令ShowDeviceAtt=》选择属性块
体现Autocad自身特性,用户易使用。


 

posted on 2009-11-03 13:54  jdmei520  阅读(1314)  评论(1编辑  收藏  举报

导航