|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# x4 A: O. O5 K/ ?& K# KUG NX 二次开发 CAM 二次开发思路及过程' Y. F9 a3 p3 S6 O5 ^$ y
7 |7 a( X8 _+ @
& r) }# b. c- K! I1. 获取当前Session:Session *theSession = Session::GetSession();+ I! t4 ^2 C; |& Z7 K: I
2. 创建文件或者打开的文件,可使用Session的方法或者直接使用UF_PART_ask_display_part()等;+ \* B$ l/ e, Q) n7 L
3. 创建CAM环境: $ ?% i( [# V. |! h
1)进入CAM模块,即创建CAMSession:theSession->CreateCamSession(); ; U( m/ P/ g- P6 ^- G9 Z( r% s
2)初始化CAM,创建CAMSetup:CAM::CAMSetup *cAMSetup = workPart->CreateCamSetup("mill_planar");, f# E8 E% ]$ W; c1 h/ U
4. 创建刀具,程序、机床、方法(四个GROUP),以刀具为例(使用UF_CAM_create_tool方法也可以创建刀具): 1)取默认的刀具group的父group: CAM::NCGroup*nCGroupP(dynamic_cast<CAM::NCGroup*>(cAMSetup->CAMGroupCollection()->FindObject("GENERIC_MACHINE")));
1 P, u- M+ W) k% | 2)调用CAMGroupCollection的CreateTool方法创建刀具:
( x9 Y" k, h5 G" t3 KCAM::NCGroup *nCGroupTool= cAMSetup->CAMGroupCollection()->CreateTool(nCGroupP, "mill_planar", "MILL",CAM::NCGroupCollection::UseDefaultNameFalse, "jorbinMIll"); 0 v) _. z& m# @4 ^9 n
3)修改刀具参数,根据刀具的类型由对应的ToolBuilder修改刀具参数(这和UF函数和NXOpen混合开放思路一样,UF函数易于创建对象,NXOpen的Builder易于修改对象参数): ' @9 z6 D! L+ d. b0 y
CAM::Tool *Milltool(dynamic_cast<CAM::Tool *>(nCGroupTool));# j ^6 ?2 r7 f- o
CAM::MillToolBuilder *millToolBuilder = cAMSetup->CAMGroupCollection()->CreateMillToolBuilder(Milltool); millToolBuilder->TlHeightBuilder()->SetValue(100.0); millToolBuilder->TlDiameterBuilder()->SetValue(44.0); NXObject *nXObject = millToolBuilder->Commit(); millToolBuilder->Destroy();) j/ g& s5 g7 J" T1 ? u
5. 创建操作: 4 @ E' A9 m/ u% R Y3 g7 n* D, L
1) 创建操作:
6 b; c& ~% Q- z& @# Y5 a CAM::Operation *operation = cAMSetup->CAMOperationCollection()->Create(nCGroup1, nCGroup2, nCGroup3, nCGroup4, "mill_planar", "FACE_MILLING_AREA", CAM::OperationCollection::UseDefaultNameFalse, "FACE_MILLING_AREA_JORBIN_GAO");
, ~7 j; h* b8 W% O7 h! z# K% x 2)修改参数,和修改刀具参数类似,通过对应的Builder完成:
$ z4 ~0 J( k% M5 Z F+ c CAM::FaceMillingBuilder *faceMillingBuilder = cAMSetup->CAMOperationCollection()->CreateFaceMillingBuilder(operation); faceMillingBuilder->FeedsBuilder()->FeedPerToothBuilder()->SetValue(10.0); NXObject *nXOpObject = faceMillingBuilder->Commit(); faceMillingBuilder->Destroy(); - P) Z: Y) Y0 j4 h% ^: A% Z* w
. N. d; W' i+ z1 S* L c$ W 注意:+ W3 R5 b( G5 U: a# b( X5 i8 h0 v
1)操作过程通过设置适度的SetUndoMark()和DeleteUndoMark()保证程序的健壮性。 2)dynamic_cast强制转换运算符将一个基类的指针或者引用转换为其子类的指针或者引用,其使用方法为:dynamic<type>(object)。 3)对上述代码有不清楚的请参阅NXOpen的文档或者自己录制Journal比较查看。
: O2 ~8 a: q" d8 B; D* t6 ^; v% S7 h! R3 w! Q2 b" c* V9 O! d
9 X5 u* F- E+ A' }
|
|