admin 发表于 2017-1-20 00:17:03

CATIA二次开发入门教程---12 为自定义的工作台添加菜单工具条

CATIA二次开发入门教程---12 为自定义的工作台添加菜单工具条


前面已经创建了工作台myWorkbench和在零件设计中添加了PLM之家智能设计的工具条和菜单,那么接下来如何在自己建的工作台上添加呢?
做法和前面类似,打开workshop.h文件,直接输入:


NewAccess(CATCmdWorkbench,CATCmdWorkbench1,myWorkbenchWkb);
SetWorkbenchPriority (CATCmdWorkbench1, 25);
NewAccess(CATCmdContainer,CATCmdContainer1,NewToolBar001Tlb);

//设置工具条


NewAccess(CATCmdStarter,pPointCmd,PointCmd);
SetAccessCommand(pPointCmd,"CreatePoint");
SetAccessChild(CATCmdContainer1,pPointCmd);
NewAccess(CATCmdStarter,pLineCmd,LineCmd);
SetAccessCommand(pLineCmd,"CreateLine");
SetAccessNext(pPointCmd,pLineCmd);
AddToolbarView(CATCmdContainer1,1,Right);
SetAccessChild(CATCmdWorkbench1,CATCmdContainer1);
//设置菜单
NewAccess(CATCmdContainer,pPartBenchMun,PartBenchMun);
NewAccess(CATCmdContainer,pPartBenchSmu,PartBenchSmu);
NewAccess(CATCmdStarter,pPointCmdm,PointCmdm);
SetAccessCommand(pPointCmdm,"CreatePoint");
NewAccess(CATCmdStarter,pLineCmdm,LineCmdm);
SetAccessCommand(pLineCmdm,"CreateLine");
SetAccessChild(pPartBenchMun,pPartBenchSmu);
SetAccessChild(pPartBenchSmu,pPointCmdm);
SetAccessNext(pPointCmdm,pLineCmdm);
SetWorkbenchMenu(CATCmdWorkbench1,pPartBenchMun);

return CATCmdWorkbench1;


注意这段代码和前面很类似,另外在headers.h中输入


new myWorkbenchCmdHeader("CreatePoint","CmdModule","PointCmd",(void *)NULL);
new myWorkbenchCmdHeader("CreateLine","CmdModule","LineCmd",(void *)NULL);


实际上现在编译的话,菜单和工具条都有啦,现在加入图片和自定义菜单名称,做法和前面一样
myWorkbenchCmdHeader.CATNls 中输入

myWorkbenchCmdHeader.CreatePoint.Title    = "创建点";
myWorkbenchCmdHeader.CreatePoint.Mnemonic   = "P";
myWorkbenchCmdHeader.CreatePoint.ShortHelp = "快速创建点";
myWorkbenchCmdHeader.CreatePoint.Help      = "创建点";
myWorkbenchCmdHeader.CreateLine.Title    = "创建线";
myWorkbenchCmdHeader.CreateLine.Mnemonic   = "L";
myWorkbenchCmdHeader.CreateLine.ShortHelp = "快速创建线";
myWorkbenchCmdHeader.CreateLine.Help      = "创建线";


myWorkbenchCmdHeader.CATRsc 中输入

myWorkbenchCmdHeader.CreatePoint.Icon.Normal    = "I_Point";
myWorkbenchCmdHeader.CreateLine.Icon.Normal    = "I_Line";

myWorkbench.CATNls 中输入:
myWorkbench.Title="PLM之家智能设计";
myWorkbench.ShortHelp= "PLM之家智能设计工具集";
myWorkbench.Help       = "PLM之家智能设计,智能设计模块";
myWorkbench.LongHelp   = "PLM之家智能设计是基于catia系统开发的一套快速智能设计模块";

NewToolBar001Tlb.Title = "PLM之家智能设计";
PartBenchSmu.Title="PLM之家智能设计";
PartBenchSmu.Mnemonic   = "P";


结果如下:








页: [1]
查看完整版本: CATIA二次开发入门教程---12 为自定义的工作台添加菜单工具条