1 // NX 1930
2 // Journal created by Administrator on Wed Jul 29 11:53:25 2020 中国标准时间
3
4 //
5 #include <uf_defs.h>
6 #include <NXOpen/NXException.hxx>
7 #include <NXOpen/Session.hxx>
8 #include <NXOpen/Axis.hxx>
9 #include <NXOpen/BasePart.hxx>
10 #include <NXOpen/Builder.hxx>
11 #include <NXOpen/CAM_AcrossVoids.hxx>
12 #include <NXOpen/CAM_ArcOutputTypeCiBuilder.hxx>
13 #include <NXOpen/CAM_AvoidanceMethodsBuilder.hxx>
14 #include <NXOpen/CAM_BlankIpw.hxx>
15 #include <NXOpen/CAM_BlankIpwMultipleSource.hxx>
16 #include <NXOpen/CAM_BlankIpwSet.hxx>
17 #include <NXOpen/CAM_BlankIpwSetList.hxx>
18 #include <NXOpen/CAM_Boundary.hxx>
19 #include <NXOpen/CAM_BoundaryPlanarMill.hxx>
20 #include <NXOpen/CAM_BoundarySet.hxx>
21 #include <NXOpen/CAM_BoundarySetList.hxx>
22 #include <NXOpen/CAM_CAMSetup.hxx>
23 #include <NXOpen/CAM_CavityMilling.hxx>
24 #include <NXOpen/CAM_CavityMillingBuilder.hxx>
25 #include <NXOpen/CAM_CleanupOutput.hxx>
26 #include <NXOpen/CAM_CleanupSettings.hxx>
27 #include <NXOpen/CAM_CornerControlBuilder.hxx>
28 #include <NXOpen/CAM_CutAngle.hxx>
29 #include <NXOpen/CAM_CutDirection.hxx>
30 #include <NXOpen/CAM_CutLevel.hxx>
31 #include <NXOpen/CAM_CutLevelPlanar.hxx>
32 #include <NXOpen/CAM_CutParameters.hxx>
33 #include <NXOpen/CAM_CutPatternBuilder.hxx>
34 #include <NXOpen/CAM_CutVolumeGeom.hxx>
35 #include <NXOpen/CAM_Cycle.hxx>
36 #include <NXOpen/CAM_DisplayPaint.hxx>
37 #include <NXOpen/CAM_DisplayPath.hxx>
38 #include <NXOpen/CAM_DisplaySilhouette.hxx>
39 #include <NXOpen/CAM_DisplayTool.hxx>
40 #include <NXOpen/CAM_ExtendAtEdges.hxx>
41 #include <NXOpen/CAM_FaceMilling.hxx>
42 #include <NXOpen/CAM_FaceMillingBuilder.hxx>
43 #include <NXOpen/CAM_FeatureGeomBuilder.hxx>
44 #include <NXOpen/CAM_FeatureGeometry.hxx>
45 #include <NXOpen/CAM_FeedsBuilder.hxx>
46 #include <NXOpen/CAM_FeedsOptimizationData.hxx>
47 #include <NXOpen/CAM_FinishPassesBuilder.hxx>
48 #include <NXOpen/CAM_Geometry.hxx>
49 #include <NXOpen/CAM_GeometryCiBuilder.hxx>
50 #include <NXOpen/CAM_GeometryGroup.hxx>
51 #include <NXOpen/CAM_GeometrySet.hxx>
52 #include <NXOpen/CAM_GeometrySetList.hxx>
53 #include <NXOpen/CAM_HoleBossGeom.hxx>
54 #include <NXOpen/CAM_Inheritable2dLength.hxx>
55 #include <NXOpen/CAM_InheritableDoubleBuilder.hxx>
56 #include <NXOpen/CAM_InheritableFeedBuilder.hxx>
57 #include <NXOpen/CAM_InheritableFeedModeBuilder.hxx>
58 #include <NXOpen/CAM_InheritableIntBuilder.hxx>
59 #include <NXOpen/CAM_InheritableTextBuilder.hxx>
60 #include <NXOpen/CAM_InheritableToolDepBuilder.hxx>
61 #include <NXOpen/CAM_LayoutCiBuilder.hxx>
62 #include <NXOpen/CAM_LevelToLevel.hxx>
63 #include <NXOpen/CAM_LowerLimit.hxx>
64 #include <NXOpen/CAM_MaxCutTraverse.hxx>
65 #include <NXOpen/CAM_Method.hxx>
66 #include <NXOpen/CAM_MillBoundaryGeomBuilder.hxx>
67 #include <NXOpen/CAM_MillCutParameters.hxx>
68 #include <NXOpen/CAM_MillGeomBuilder.hxx>
69 #include <NXOpen/CAM_MillOperationBuilder.hxx>
70 #include <NXOpen/CAM_MinCutVolume.hxx>
71 #include <NXOpen/CAM_MultiBladeBaseGeometry.hxx>
72 #include <NXOpen/CAM_MultiBladeSplittersGeometry.hxx>
73 #include <NXOpen/CAM_MultiDepthCut.hxx>
74 #include <NXOpen/CAM_MultiplePassesBuilder.hxx>
75 #include <NXOpen/CAM_MultipleStepoverBuilder.hxx>
76 #include <NXOpen/CAM_NCGroup.hxx>
77 #include <NXOpen/CAM_NCGroupBuilder.hxx>
78 #include <NXOpen/CAM_NCGroupCollection.hxx>
79 #include <NXOpen/CAM_NcmAvoidancePointBuilder.hxx>
80 #include <NXOpen/CAM_NcmClearanceBuilder.hxx>
81 #include <NXOpen/CAM_NcmPlanarBuilder.hxx>
82 #include <NXOpen/CAM_NcmPlanarEngRetBuilder.hxx>
83 #include <NXOpen/CAM_NcmSmoothingBuilder.hxx>
84 #include <NXOpen/CAM_NcmSubopBuilder.hxx>
85 #include <NXOpen/CAM_NcmTransfer.hxx>
86 #include <NXOpen/CAM_Notes.hxx>
87 #include <NXOpen/CAM_Operation.hxx>
88 #include <NXOpen/CAM_OperationBuilder.hxx>
89 #include <NXOpen/CAM_OperationCollection.hxx>
90 #include <NXOpen/CAM_OperationDisplayOptionsBuilder.hxx>
91 #include <NXOpen/CAM_OutputUncutRegions.hxx>
92 #include <NXOpen/CAM_ParamBuilder.hxx>
93 #include <NXOpen/CAM_PathDisplayColors.hxx>
94 #include <NXOpen/CAM_PlanarMilling.hxx>
95 #include <NXOpen/CAM_PlanarMillingBuilder.hxx>
96 #include <NXOpen/CAM_PlanarOperationBuilder.hxx>
97 #include <NXOpen/CAM_PostEventsCiBuilder.hxx>
98 #include <NXOpen/CAM_RoundPointBuilder.hxx>
99 #include <NXOpen/CAM_SmallAreaAvoidance.hxx>
100 #include <NXOpen/CAM_Splitter.hxx>
101 #include <NXOpen/CAM_SplitterList.hxx>
102 #include <NXOpen/CAM_SpunOutlineGeom.hxx>
103 #include <NXOpen/CAM_SteepContainment.hxx>
104 #include <NXOpen/CAM_StepoverBuilder.hxx>
105 #include <NXOpen/CAM_StockPerPassBuilder.hxx>
106 #include <NXOpen/CAM_Tool.hxx>
107 #include <NXOpen/CAM_ToolAxisBase.hxx>
108 #include <NXOpen/CAM_ToolAxisChange.hxx>
109 #include <NXOpen/CAM_ToolAxisFixed.hxx>
110 #include <NXOpen/CAM_ToolAxisTilt.hxx>
111 #include <NXOpen/CAM_ToolChangeCiBuilder.hxx>
112 #include <NXOpen/CAM_ToolPathEditorBuilder.hxx>
113 #include <NXOpen/CAM_ToolPathSplitParametersBuilder.hxx>
114 #include <NXOpen/CAM_Topology.hxx>
115 #include <NXOpen/CAM_TrochoidalSettings.hxx>
116 #include <NXOpen/CAM_Ude.hxx>
117 #include <NXOpen/CAM_UdeList.hxx>
118 #include <NXOpen/CAM_UdeSet.hxx>
119 #include <NXOpen/CAM_UpDownCutting.hxx>
120 #include <NXOpen/CAM_ZAxisSmoothing.hxx>
121 #include <NXOpen/CartesianCoordinateSystem.hxx>
122 #include <NXOpen/CoordinateSystem.hxx>
123 #include <NXOpen/CAM_ParamBuilder.hxx>
124 #include <NXOpen/CAM_ProgramOrderGroupBuilder.hxx>
125 #include <NXOpen/Direction.hxx>
126 #include <NXOpen/Expression.hxx>
127 #include <NXOpen/ExpressionCollection.hxx>
128 #include <NXOpen/IPlane.hxx>
129 #include <NXOpen/NXObject.hxx>
130 #include <NXOpen/Part.hxx>
131 #include <NXOpen/PartCollection.hxx>
132 #include <NXOpen/Plane.hxx>
133 #include <NXOpen/PlaneCollection.hxx>
134 #include <NXOpen/Point.hxx>
135 #include <NXOpen/PreviewBuilder.hxx>
136 #include <NXOpen/ScCollector.hxx>
137 #include <NXOpen/Session.hxx>
138 #include <NXOpen/SmartObject.hxx>
139 #include <NXOpen/Unit.hxx>
140 #include <NXOpen/UnitCollection.hxx>
141
142 #include "C:\\all_uf.h"
143
144 #include <NXOpen/CAM_CAMSession.hxx>
145 #include <NXOpen/CAM_CAMSetup.hxx>
146 #include <NXOpen/CAM_PathDisplay.hxx>
147 #include <NXOpen/Part.hxx>
148 #include <NXOpen/PartCollection.hxx>
149 #include <NXOpen/SIM_KinematicConfigurator.hxx>
150 #include <NXOpen/CAM_Cycle.hxx>
151 #include <NXOpen/CAM_HolderSectionBuilder.hxx>
152 #include <NXOpen/CAM_InheritableDoubleBuilder.hxx>
153 #include <NXOpen/CAM_InheritableIntBuilder.hxx>
154 #include <NXOpen/CAM_InheritableToolDepBuilder.hxx>
155 #include <NXOpen/CAM_MillToolBuilder.hxx>
156 #include <NXOpen/CAM_MillingToolBuilder.hxx>
157 #include <NXOpen/CAM_MillingTrackpointBuilder.hxx>
158 #include <NXOpen/CAM_NCGroup.hxx>
159 #include <NXOpen/CAM_NCGroupBuilder.hxx>
160 #include <NXOpen/CAM_NCGroupCollection.hxx>
161 #include <NXOpen/CAM_ParamBuilder.hxx>
162 #include <NXOpen/CAM_Tool.hxx>
163 #include <NXOpen/CAM_ToolBuilder.hxx>
164 #include <NXOpen/CAM_Ude.hxx>
165 #include <NXOpen/CAM_UdeList.hxx>
166 #include <NXOpen/CAM_UdeSet.hxx>
167 #include <NXOpen/NXObject.hxx>
168
169 #include <NXOpen/CAM_NcmAvoidancePointBuilder.hxx>
170 #include <NXOpen/CAM_NcmClearanceBuilder.hxx>
171 #include <NXOpen/CAM_OrientGeomBuilder.hxx>
172 #include <NXOpen/CAM_OrientGeometry.hxx>
173 #include <NXOpen/CAM_InheritableIntBuilder.hxx>
174 #include <NXOpen/CAM_LayoutCiBuilder.hxx>
175 #include <NXOpen/CAM_MillOrientGeomBuilder.hxx>
176
177 #include <NXOpen/CAM_CutParameters.hxx>
178 #include <NXOpen/CAM_Method.hxx>
179 #include <NXOpen/CAM_MethodBuilder.hxx>
180 #include <NXOpen/CAM_MillMethodBuilder.hxx>
181
182 #define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
183
184 static int report_error(char *file, int line, char *call, int irc)
185 {
186 if (irc)
187 {
188 char err[133], msg[133];
189 sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
190 irc, line, file);
191 UF_get_fail_message(irc, err);
192 UF_print_syslog(msg, FALSE);
193 UF_print_syslog(err, FALSE);
194 UF_print_syslog("\n", FALSE);
195 UF_print_syslog(call, FALSE);
196 UF_print_syslog(";\n", FALSE);
197
198 if (!UF_UI_open_listing_window())
199 {
200 UF_UI_write_listing_window(msg);
201 UF_UI_write_listing_window(err);
202 UF_UI_write_listing_window("\n");
203 UF_UI_write_listing_window(call);
204 UF_UI_write_listing_window(";\n");
205 }
206 }
207 return(irc);
208 }
209
210 // We are currently testing removal of using namespace NXOpen.
211 // Uncomment the below line if your journal does not compile.
212 using namespace NXOpen;
213
214 extern "C" DllExport int ufusr_ask_unload()
215 {
216 return (int)Session::LibraryUnloadOptionImmediately;
217 }
218
219 static void createTool()//创建刀具
220 {
221 NXOpen::Session *theSession = NXOpen::Session::GetSession();
222 NXOpen::Part *workPart(theSession->Parts()->Work());
223 NXOpen::Part *displayPart(theSession->Parts()->Display());
224 NXOpen::CAM::NCGroup *nCGroup1(dynamic_cast<NXOpen::CAM::NCGroup *>(workPart->CAMSetup()->CAMGroupCollection()->FindObject("GENERIC_MACHINE")));
225 NXOpen::CAM::NCGroup *nCGroup2;
226 nCGroup2 = workPart->CAMSetup()->CAMGroupCollection()->CreateTool(nCGroup1, "mill_planar", "MILL", NXOpen::CAM::NCGroupCollection::UseDefaultNameFalse, "D8");
227
228 NXOpen::CAM::Tool *tool1(dynamic_cast<NXOpen::CAM::Tool *>(nCGroup2));
229 NXOpen::CAM::MillToolBuilder *millToolBuilder1;
230 millToolBuilder1 = workPart->CAMSetup()->CAMGroupCollection()->CreateMillToolBuilder(tool1);
231 // ----------------------------------------------
232 millToolBuilder1->TlDiameterBuilder()->SetValue(8.0);
233 millToolBuilder1->TlNumberBuilder()->SetValue(8);
234 millToolBuilder1->TlAdjRegBuilder()->SetValue(0);
235 millToolBuilder1->TlCutcomRegBuilder()->SetValue(0);
236 NXOpen::NXObject *nXObject1;
237 nXObject1 = millToolBuilder1->Commit();
238 millToolBuilder1->Destroy();
239
240 }
241
242 static void Create_Method(char *str)//创建方法
243 {
244 NXOpen::Session *theSession = NXOpen::Session::GetSession();
245 NXOpen::Part *workPart(theSession->Parts()->Work());
246 NXOpen::Part *displayPart(theSession->Parts()->Display());
247 NXOpen::CAM::Method *method1(dynamic_cast<NXOpen::CAM::Method *>(workPart->CAMSetup()->CAMGroupCollection()->FindObject("METHOD")));
248 NXOpen::CAM::NCGroup *nCGroup0;
249 nCGroup0 = workPart->CAMSetup()->CAMGroupCollection()->CreateMethod(method1, "NF", "0", NXOpen::CAM::NCGroupCollection::UseDefaultNameFalse, str);
250 NXOpen::CAM::Method *method2(dynamic_cast<NXOpen::CAM::Method *>(nCGroup0));
251 NXOpen::CAM::MillMethodBuilder *millMethodBuilder1;
252 millMethodBuilder1 = workPart->CAMSetup()->CAMGroupCollection()->CreateMillMethodBuilder(method2);
253 millMethodBuilder1->CutParameters()->PartStock()->SetValue(0.07);
254 NXOpen::NXObject *nXObject1;
255 nXObject1 = millMethodBuilder1->Commit();
256 millMethodBuilder1->Destroy();
257 }
258
259 static void create_mcs(char *msc)//创建MCS
260 {
261 NXOpen::Session *theSession = NXOpen::Session::GetSession();
262 NXOpen::Part *workPart(theSession->Parts()->Work());
263 NXOpen::Part *displayPart(theSession->Parts()->Display());
264 NXOpen::CAM::NCGroup *nCGroup2(dynamic_cast<NXOpen::CAM::NCGroup *>(workPart->CAMSetup()->CAMGroupCollection()->FindObject("GEOMETRY")));
265 NXOpen::CAM::NCGroup *nCGroup3;
266 nCGroup3 = workPart->CAMSetup()->CAMGroupCollection()->CreateGeometry(nCGroup2, "NF", "MCS", NXOpen::CAM::NCGroupCollection::UseDefaultNameFalse, msc);
267 NXOpen::CAM::OrientGeometry *orientGeometry1(dynamic_cast<NXOpen::CAM::OrientGeometry *>(nCGroup3));
268 NXOpen::CAM::MillOrientGeomBuilder *millOrientGeomBuilder1;
269 millOrientGeomBuilder1 = workPart->CAMSetup()->CAMGroupCollection()->CreateMillOrientGeomBuilder(orientGeometry1);
270 NXOpen::CAM::OrientGeomBuilder::CsysPurposeModes csyspurposemode1;
271 csyspurposemode1 = millOrientGeomBuilder1->GetCsysPurposeMode();
272 NXOpen::CAM::OrientGeomBuilder::SpecialOutputModes specialoutputmode1;
273 specialoutputmode1 = millOrientGeomBuilder1->GetSpecialOutputMode();
274 NXOpen::CAM::OrientGeomBuilder::ToolAxisModes toolaxismode1;
275 toolaxismode1 = millOrientGeomBuilder1->GetToolAxisMode();
276 NXOpen::Point3d origin1(0.0, 0.0, 0.0);
277 NXOpen::Vector3d normal1(0.0, 0.0, 1.0);
278 NXOpen::Plane *plane1;
279 plane1 = workPart->Planes()->CreatePlane(origin1, normal1, NXOpen::SmartObject::UpdateOptionAfterModeling);
280 NXOpen::CAM::MillOrientGeomBuilder::LowerLimitModes lowerlimitmode1;
281 lowerlimitmode1 = millOrientGeomBuilder1->GetLowerLimitMode();
282 NXOpen::NXObject *nXObject1;
283 nXObject1 = millOrientGeomBuilder1->Commit();
284 millOrientGeomBuilder1->Destroy();
285 plane1->DestroyPlane();
286 }
287
288 extern "C" DllExport void ufusr(char* param, int* retCode, int paramLen)
289 {
290 try
291 {
292 UF_initialize();
293 Session* theSession = Session::GetSession();
294 Part* workPart(theSession->Parts()->Work());
295 Part* displayPart(theSession->Parts()->Display());
296 tag_t Tooltag = NULL_TAG;
297 tag_t setuptag = NULL_TAG;
298 tag_t mctTag = NULL_TAG;
299 tag_t geomtag = NULL_TAG;
300 tag_t MCStag = NULL_TAG;
301 tag_t Meth_tag = NULL_TAG;
302 tag_t ncMeth_tag = NULL_TAG;
303
304 UF_SETUP_ask_setup(&setuptag);
305 CAM::CAMSetup *cAMSetup1;
306 cAMSetup1 = workPart->CreateCamSetup("NF");
307 CAM::NCGroup* nCGroup1;
308 UF_SETUP_ask_geom_root(setuptag, &geomtag);//获取几何TAG
309 UF_NCGROUP_ask_object_of_name(geomtag, "MCS_MILL", &MCStag);
310 if (MCStag)
311 {
312 nCGroup1 = (dynamic_cast<CAM::NCGroup*>(workPart->CAMSetup()->CAMGroupCollection()->FindObject("MCS_MILL")));
313 }
314 else
315 {
316 create_mcs("MCS_MILL");
317 nCGroup1 = (dynamic_cast<CAM::NCGroup*>(workPart->CAMSetup()->CAMGroupCollection()->FindObject("MCS_MILL")));
318 }
319 //设置安全高度
320 MCStag = workPart->CAMSetup()->CAMGroupCollection()->FindObject("MCS_MILL")->Tag();
321 double origin[3] = { 0.0,0.0,30.0 };
322 double normal[3] = { 0.0,0.0,1.0 };
323 int err = UF_CAM_set_clear_plane_data(MCStag, origin, normal);
324 if (err)
325 {
326 char msg[256];
327 UF_get_fail_message(err, msg);
328 uc1601(msg, 1);
329 }
330 CAM::NCGroup* nCGroup4;
331 nCGroup4 = workPart->CAMSetup()->CAMGroupCollection()->CreateGeometry(nCGroup1, "NF", "WORKPIECE", CAM::NCGroupCollection::UseDefaultNameTrue, "WORKPIECE");//使用默认名
332 CAM::FeatureGeometry* featureGeometry1(dynamic_cast<CAM::FeatureGeometry*>(nCGroup4));
333 CAM::MillGeomBuilder* millGeomBuilder1;
334 millGeomBuilder1 = workPart->CAMSetup()->CAMGroupCollection()->CreateMillGeomBuilder(featureGeometry1);
335 NXObject* nXObject1;
336 nXObject1 = millGeomBuilder1->Commit();
337 millGeomBuilder1->Destroy();
338
339 int count = 0;
340 char obj_name[256] = "";
341 char obj_name1[256] = "";
342 tag_t* objects = NULL;
343 CAM::NCGroup* nCGroup3;
344 UF_UI_ONT_ask_selected_nodes(&count, &objects);
345 if (objects != NULL)
346 {
347 int Type = 0, Subtype = 0;
348 UF_OBJ_ask_type_and_subtype(objects[0], &Type, &Subtype);
349 if (Type == UF_machining_task_type && Subtype == UF_mach_order_task_subtype)
350 {
351 UF_OBJ_ask_name(objects[0], obj_name);
352 nCGroup3 = workPart->CAMSetup()->CAMGroupCollection()->FindObject(obj_name);
353 }
354 else
355 {
356 CAM::NCGroup* nCGroup;
357 UF_OBJ_ask_name(objects[0], obj_name1);
358 nCGroup = workPart->CAMSetup()->CAMGroupCollection()->FindObject(obj_name1);
359 nCGroup3 = nCGroup->GetParent();
360 }
361 }
362 else
363 {
364 tag_t programs = NULL_TAG;
365 UF_OBJ_cycle_by_name_and_type(UF_ASSEM_ask_work_part(), "PROGRAM", UF_machining_task_type, false, &programs);
366 if (programs)
367 nCGroup3 = workPart->CAMSetup()->CAMGroupCollection()->FindObject("PROGRAM");
368 else
369 {
370 CAM::NCGroup *NCGroup1(dynamic_cast<CAM::NCGroup *>(workPart->CAMSetup()->CAMGroupCollection()->FindObject("NC_PROGRAM")));
371 CAM::NCGroup *NCGroup2;
372 NCGroup2 = workPart->CAMSetup()->CAMGroupCollection()->CreateProgram(NCGroup1, "NF", "PROGRAM", CAM::NCGroupCollection::UseDefaultNameTrue, "PROGRAM");
373 CAM::ProgramOrderGroupBuilder *programOrderGroupBuilder1;
374 programOrderGroupBuilder1 = workPart->CAMSetup()->CAMGroupCollection()->CreateProgramOrderGroupBuilder(NCGroup1);
375 NXObject *NXObject1;
376 NXObject1 = programOrderGroupBuilder1->Commit();
377 programOrderGroupBuilder1->Destroy();
378 nCGroup3 = NCGroup2;
379 }
380 }
381 UF_SETUP_ask_mthd_root(setuptag, &Meth_tag);
382 UF_NCGROUP_ask_object_of_name(Meth_tag, "0.07", &ncMeth_tag);
383 CAM::Method* method1;
384 if (ncMeth_tag)
385 {
386 method1=dynamic_cast<CAM::Method*>(workPart->CAMSetup()->CAMGroupCollection()->FindObject("0.07"));
387 }
388 else
389 {
390 Create_Method("0.07");//创建方法
391 method1 = dynamic_cast<CAM::Method*>(workPart->CAMSetup()->CAMGroupCollection()->FindObject("0.07"));
392 }
393 CAM::Tool* tool1;
394 UF_SETUP_ask_mct_root(setuptag, &mctTag);
395 UF_NCGROUP_ask_object_of_name(mctTag, "D8", &Tooltag);
396 if (Tooltag) //存在
397 {
398 tool1 = dynamic_cast<CAM::Tool*>(workPart->CAMSetup()->CAMGroupCollection()->FindObject("D8"));
399 }
400 else //不存在
401 {
402 createTool(); //创建一把刀
403 tool1 = dynamic_cast<CAM::Tool*>(workPart->CAMSetup()->CAMGroupCollection()->FindObject("D8"));
404 }
405 CAM::FeatureGeometry* featureGeometry2(dynamic_cast<CAM::FeatureGeometry*>(nXObject1));
406 CAM::Operation* operation1;
407 operation1 = workPart->CAMSetup()->CAMOperationCollection()->Create(nCGroup3, method1, tool1, featureGeometry2, "NF", "FACE_M", CAM::OperationCollection::UseDefaultNameTrue, "FACE_M");
408 CAM::FaceMilling* faceMilling1(dynamic_cast<CAM::FaceMilling*>(operation1));
409 CAM::FaceMillingBuilder* faceMillingBuilder1;
410 Direction* nullNXOpen_Direction(NULL);
411 faceMillingBuilder1 = workPart->CAMSetup()->CAMOperationCollection()->CreateFaceMillingBuilder(faceMilling1);
412 // ----------------------------------------------
413 // Dialog Begin Face M - [FACE_M]
414 // ----------------------------------------------
415 faceMillingBuilder1->NonCuttingBuilder()->EngageOpenAreaBuilder()->SetVector(nullNXOpen_Direction);
416 faceMillingBuilder1->CutParameters()->FloorStock()->SetValue(0.0);//底部余量
417 faceMillingBuilder1->CutParameters()->SetExtendToPart(true);//延伸到部件轮廓
418 faceMillingBuilder1->BndStepover()->PercentToolFlatBuilder()->SetValue(50.0);//平面刀具直径百分比
419 faceMillingBuilder1->CutParameters()->BlankDistance()->SetValue(0.50);//毛坯距离
420 faceMillingBuilder1->DepthPerCut()->SetValue(0.0);//每刀深度
421 faceMillingBuilder1->FeedsBuilder()->FeedCutBuilder()->SetValue(2000.0);//进给
422 faceMillingBuilder1->NonCuttingBuilder()->EngageClosedAreaBuilder()->SetEngRetType(CAM::NcmPlanarEngRetBuilder::EngRetTypesSameAsEngage);//进刀
423 faceMillingBuilder1->FeedsBuilder()->SpindleRpmBuilder()->SetValue(6000.0);//主轴转速
424 //faceMillingBuilder1->FeedsBuilder()->RecalculateData(CAM::FeedsBuilder::RecalcuateBasedOnSpindleSpeed);//计算器
425 NXObject* nXObject2;
426 nXObject2 = faceMillingBuilder1->Commit();
427 faceMillingBuilder1->Destroy();
428
429 // ----------------------------------------------
430 // Dialog Begin Cavity M - [CAVITY_M]
431 // ----------------------------------------------
432 CAM::Operation* operation2;
433 operation2 = workPart->CAMSetup()->CAMOperationCollection()->Create(nCGroup3, method1, tool1, featureGeometry2, "NF", "CAVITY_M", CAM::OperationCollection::UseDefaultNameTrue, "CAVITY_M");
434 CAM::CavityMilling* cavityMilling1(dynamic_cast<CAM::CavityMilling*>(operation2));
435 CAM::CavityMillingBuilder* cavityMillingBuilder1;
436 cavityMillingBuilder1 = workPart->CAMSetup()->CAMOperationCollection()->CreateCavityMillingBuilder(cavityMilling1);
437 cavityMillingBuilder1->CutParameters()->PartStock()->SetValue(0.1);
438 cavityMillingBuilder1->BndStepover()->PercentToolFlatBuilder()->SetValue(60.0);//平面刀具直径百分比
439 cavityMillingBuilder1->CutLevel()->GlobalDepthPerCut()->DistanceBuilder()->SetValue(0.5);
440 cavityMillingBuilder1->CutParameters()->SetPatternDirection(CAM::CutParametersPatternDirectionTypesInward);//向内
441 cavityMillingBuilder1->NonCuttingBuilder()->EngageOpenAreaBuilder()->SetVector(nullNXOpen_Direction);
442 cavityMillingBuilder1->SetIslandCleanup(true);//设置孤岛清理
443 cavityMillingBuilder1->NonCuttingBuilder()->EngageClosedAreaBuilder()->SetEngRetType(CAM::NcmPlanarEngRetBuilder::EngRetTypesSameAsEngage);
444 cavityMillingBuilder1->NonCuttingBuilder()->EngageOpenAreaBuilder()->HeightBuilder()->SetValue(1.0);//进刀高度
445 //cavityMillingBuilder1->FeedsBuilder()->RecalculateData(CAM::FeedsBuilder::RecalcuateBasedOnSpindleSpeed);
446 cavityMillingBuilder1->FeedsBuilder()->FeedCutBuilder()->SetValue(2000.0);
447 cavityMillingBuilder1->FeedsBuilder()->SpindleRpmBuilder()->SetValue(6000.0);
448 //cavityMillingBuilder1->FeedsBuilder()->RecalculateData(CAM::FeedsBuilder::RecalcuateBasedOnCutFeedRate);
449 NXObject* nXObject3;
450 nXObject3 = cavityMillingBuilder1->Commit();
451 cavityMillingBuilder1->Destroy();
452 // ----------------------------------------------
453 // Dialog Begin 铣削边界
454 // ----------------------------------------------
455 CAM::NCGroup* nCGroup5;
456 nCGroup5 = workPart->CAMSetup()->CAMGroupCollection()->CreateGeometry(featureGeometry2, "NF", "MILL_BND", CAM::NCGroupCollection::UseDefaultNameTrue, "MILL_BND");//使用默认名创建边界
457 CAM::FeatureGeometry* featureGeometry3(dynamic_cast<CAM::FeatureGeometry*>(nCGroup5));
458 CAM::MillBoundaryGeomBuilder* millBoundaryGeomBuilder1;
459 millBoundaryGeomBuilder1 = workPart->CAMSetup()->CAMGroupCollection()->CreateMillBoundaryGeomBuilder(featureGeometry3);
460 NXObject* nXObject5;
461 nXObject5 = millBoundaryGeomBuilder1->Commit();
462 millBoundaryGeomBuilder1->Destroy();
463 // ----------------------------------------------
464 // Dialog Begin Wx 1 - [WX_1]
465 // ----------------------------------------------
466 CAM::FeatureGeometry* featureGeometry4(dynamic_cast<CAM::FeatureGeometry*>(nXObject5));
467 CAM::Operation* operation3;
468 operation3 = workPart->CAMSetup()->CAMOperationCollection()->Create(nCGroup3, method1, tool1, featureGeometry4, "NF", "WX_1", CAM::OperationCollection::UseDefaultNameTrue, "WX_1");
469 CAM::PlanarMilling* planarMilling1(dynamic_cast<CAM::PlanarMilling*>(operation3));
470 CAM::PlanarMillingBuilder* planarMillingBuilder1;
471 planarMillingBuilder1 = workPart->CAMSetup()->CAMOperationCollection()->CreatePlanarMillingBuilder(planarMilling1);
472 planarMillingBuilder1->CutLevel()->CommonDepth()->SetValue(0.5);
473 planarMillingBuilder1->NonCuttingBuilder()->OverlapDistanceBuilder()->SetValue(0.2);//重叠距离
474 planarMillingBuilder1->FeedsBuilder()->SpindleRpmBuilder()->SetValue(6000);
475 planarMillingBuilder1->FeedsBuilder()->FeedCutBuilder()->SetValue(2200.0);
476 //planarMillingBuilder1->FeedsBuilder()->RecalculateData(CAM::FeedsBuilder::RecalcuateBasedOnSpindleSpeed);
477 NXObject* nXObject6;
478 nXObject6 = planarMillingBuilder1->Commit();
479 planarMillingBuilder1->Destroy();
480 // ----------------------------------------------
481 // Dialog Begin Mill F - [MILL_F]
482 // ----------------------------------------------
483 CAM::Operation* operation4;
484 operation4 = workPart->CAMSetup()->CAMOperationCollection()->Create(nCGroup3, method1, tool1, featureGeometry4, "NF", "MILL_F", CAM::OperationCollection::UseDefaultNameTrue, "MILL_F");
485 CAM::PlanarMilling* planarMilling2(dynamic_cast<CAM::PlanarMilling*>(operation4));
486 CAM::PlanarMillingBuilder* planarMillingBuilder2;
487 planarMillingBuilder2 = workPart->CAMSetup()->CAMOperationCollection()->CreatePlanarMillingBuilder(planarMilling2);
488 planarMillingBuilder2->CutParameters()->PartStock()->SetValue(0.0);
489 planarMillingBuilder2->CutParameters()->FloorStock()->SetValue(0.0);
490 CAM::Inheritable2dLength* inheritable2dLength1;
491 inheritable2dLength1 = planarMillingBuilder2->CutParameters()->Tolerances();
492 inheritable2dLength1->SetValue0(0.005);
493 inheritable2dLength1->SetValue1(0.005);
494 planarMillingBuilder2->CutLevel()->SetCutLevelType(CAM::CutLevelPlanar::TypesFloorOnly);
495 planarMillingBuilder2->NonCuttingBuilder()->OverlapDistanceBuilder()->SetValue(0.2);
496 planarMillingBuilder2->NonCuttingBuilder()->SetDefaultRegionStartType(CAM::NcmSubopBuilder::DefaultRegionStartTypesCorner);
497 planarMillingBuilder2->FeedsBuilder()->SpindleRpmBuilder()->SetValue(7000.0);
498 planarMillingBuilder2->FeedsBuilder()->FeedCutBuilder()->SetValue(1500.0);
499 //planarMillingBuilder2->FeedsBuilder()->RecalculateData(CAM::FeedsBuilder::RecalcuateBasedOnSpindleSpeed);
500 NXObject* nXObject7;
501 nXObject7 = planarMillingBuilder2->Commit();
502 planarMillingBuilder2->Destroy();
503 UF_terminate();
504 }
505 catch (...)
506 {
507 uc1601("操作失败!*请检查日志文件", 1);
508 }
509 }