NXopen create chamfer tool

 1 void Create_chamfer_tool( char *toolName,double 直径,int 刀具号)
 2 {
 3     NXOpen::Session *theSession = NXOpen::Session::GetSession();
 4     NXOpen::Part *workPart(theSession->Parts()->Work());
 5     NXOpen::Part *displayPart(theSession->Parts()->Display());
 6     // ----------------------------------------------
 7     NXOpen::CAM::NCGroup *nCGroup1(dynamic_cast<NXOpen::CAM::NCGroup *>(workPart->CAMSetup()->CAMGroupCollection()->FindObject("GENERIC_MACHINE")));
 8     NXOpen::CAM::NCGroup *nCGroup2;
 9     nCGroup2 = workPart->CAMSetup()->CAMGroupCollection()->CreateTool(nCGroup1, "mill_planar", "CHAMFER_MILL", NXOpen::CAM::NCGroupCollection::UseDefaultNameFalse, toolName);
10     NXOpen::CAM::Tool *tool1(dynamic_cast<NXOpen::CAM::Tool *>(nCGroup2));
11     NXOpen::CAM::MillToolBuilder *millToolBuilder1;
12     millToolBuilder1 = workPart->CAMSetup()->CAMGroupCollection()->CreateMillToolBuilder(tool1);
13 
14     millToolBuilder1->SetDescription(toolName);//描述
15     millToolBuilder1->TlDiameterBuilder()->SetValue(直径);//直径
16     millToolBuilder1->TlTaperAngBuilder()->SetValue(45.0);//斜角角度
17     millToolBuilder1->ChamferLengthBuilder()->SetValue(直径 / 2.0);//斜角长度
18     millToolBuilder1->TlHeightBuilder()->SetValue(100);//刀具高度
19     millToolBuilder1->TlFluteLnBuilder()->SetValue(5);//刀刃长度
20     millToolBuilder1->TlNumFlutesBuilder()->SetValue(3);//刀刃数量
21     millToolBuilder1->TlNumberBuilder()->SetValue(刀具号);//刀号
22     millToolBuilder1->TlAdjRegBuilder()->SetValue(刀具号);//补偿寄存器
23     millToolBuilder1->TlCutcomRegBuilder()->SetValue(刀具号);//刀具补偿寄存器
24 
25     NXOpen::NXObject *nXObject1;
26     nXObject1 = millToolBuilder1->Commit();
27     millToolBuilder1->Destroy();
28 }

 

posted @ 2020-07-14 16:30  老婆饼里有老婆  阅读(308)  评论(0编辑  收藏  举报