|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
2 U" `4 @0 Q: L# o, o5 f3 b+ {
UG NX 二次开发 CAM 二次开发思路及过程5 r G7 c5 c6 z5 X4 g" |: ?' D
5 p5 x- m1 c1 x* X
& l+ S9 K; W# V/ r; n C1. 获取当前Session:Session *theSession = Session::GetSession();6 |( \7 b u. c- P/ x* I
2. 创建文件或者打开的文件,可使用Session的方法或者直接使用UF_PART_ask_display_part()等;* n! F! M C4 a: x3 s
3. 创建CAM环境:
u1 I. T4 ~5 [5 e" | 1)进入CAM模块,即创建CAMSession:theSession->CreateCamSession();
$ b4 A* [ n9 a 2)初始化CAM,创建CAMSetup:CAM::CAMSetup *cAMSetup = workPart->CreateCamSetup("mill_planar");6 k& R& K( Z3 b+ f- Z! O
4. 创建刀具,程序、机床、方法(四个GROUP),以刀具为例(使用UF_CAM_create_tool方法也可以创建刀具): 1)取默认的刀具group的父group: CAM::NCGroup*nCGroupP(dynamic_cast<CAM::NCGroup*>(cAMSetup->CAMGroupCollection()->FindObject("GENERIC_MACHINE"))); 4 ?0 u8 M. V+ b9 R1 U) w% l+ m
2)调用CAMGroupCollection的CreateTool方法创建刀具:
, g i2 n2 r. ICAM::NCGroup *nCGroupTool= cAMSetup->CAMGroupCollection()->CreateTool(nCGroupP, "mill_planar", "MILL",CAM::NCGroupCollection::UseDefaultNameFalse, "jorbinMIll");
4 Q0 h% {3 A8 z8 G6 L 3)修改刀具参数,根据刀具的类型由对应的ToolBuilder修改刀具参数(这和UF函数和NXOpen混合开放思路一样,UF函数易于创建对象,NXOpen的Builder易于修改对象参数):
5 \+ D- O% p' ^; R7 r* ^0 Y CAM::Tool *Milltool(dynamic_cast<CAM::Tool *>(nCGroupTool));
. @% K6 D4 U0 @: u5 @% k CAM::MillToolBuilder *millToolBuilder = cAMSetup->CAMGroupCollection()->CreateMillToolBuilder(Milltool); millToolBuilder->TlHeightBuilder()->SetValue(100.0); millToolBuilder->TlDiameterBuilder()->SetValue(44.0); NXObject *nXObject = millToolBuilder->Commit(); millToolBuilder->Destroy();0 ~! I* P9 L3 G4 R2 F
5. 创建操作: ' x% m; Y* A) Q1 w7 b; b; _% W
1) 创建操作:- _( y, D8 k$ E, E9 u& p! [
CAM::Operation *operation = cAMSetup->CAMOperationCollection()->Create(nCGroup1, nCGroup2, nCGroup3, nCGroup4, "mill_planar", "FACE_MILLING_AREA", CAM::OperationCollection::UseDefaultNameFalse, "FACE_MILLING_AREA_JORBIN_GAO");
. x8 s7 `8 t( c4 T! t6 M2 L6 ` 2)修改参数,和修改刀具参数类似,通过对应的Builder完成:
; a$ b; P& y% G0 j7 A; G: Z CAM::FaceMillingBuilder *faceMillingBuilder = cAMSetup->CAMOperationCollection()->CreateFaceMillingBuilder(operation); faceMillingBuilder->FeedsBuilder()->FeedPerToothBuilder()->SetValue(10.0); NXObject *nXOpObject = faceMillingBuilder->Commit(); faceMillingBuilder->Destroy(); * s/ M R) V; l2 l1 h2 b& Q
1 f3 h, g( i: F- \( O' u 注意:* b6 g/ h+ ^" }9 O5 y
1)操作过程通过设置适度的SetUndoMark()和DeleteUndoMark()保证程序的健壮性。 2)dynamic_cast强制转换运算符将一个基类的指针或者引用转换为其子类的指针或者引用,其使用方法为:dynamic<type>(object)。 3)对上述代码有不清楚的请参阅NXOpen的文档或者自己录制Journal比较查看。6 y. N& e7 v F4 _$ e h
) u+ S' q/ ]) w, g. f# A8 J5 ]- ]/ s* D+ B9 m% Y1 D" c
|
|