Ref: Auto
cad2008
Help + Objectarx for 2008
1.参考编辑
属
性块
命
令:eattedit,实现双击属性块执行
自
定义宏命令ShowDeviceAtt。
说明:执行dblclick、savecui ,只需要第一次使用时注册双击命令即可,适合在安装包中注册与恢复。
测试打开属性块编辑
窗
口2种方式:
1.双击属性块
2.输入命令ShowDeviceAtt=》选择属性块
体现Autocad自身特性,
用户易使用。
[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("属性块双击自定义动作添加成功");
}
转自: http://www.cnblogs.com/jdmei520/archive/2009/11/03/1595033.html