1 NX11+VS2013 2 3 #include <uf.h> 4 #include <uf_view.h> 5 #include <uf_obj.h> 6 #include <uf_part.h> 7 #include <NXOpen/Layout.hxx> 8 #include <NXOpen/LayoutCollection.hxx> 9 #include <NXOpen/ModelingView.hxx> 10 #include <NXOpen/ModelingViewCollection.hxx> 11 #include <NXOpen/View.hxx> 12 #include <NXOpen/ViewCollection.hxx> 13 14 UF_initialize(); 15 16 //获得视图的tag 17 tag_t BackTag = NULL_TAG; 18 UF_OBJ_cycle_by_name_and_type(UF_PART_ask_display_part(), "Back", UF_view_type, false, &BackTag); 19 20 //设置视图为工作视图 21 workPart->ModelingViews()->WorkView()->Orient(NXOpen::View::CannedBack, NXOpen::View::ScaleAdjustmentFit); 22 23 NXOpen::Layout *layout1(dynamic_cast<NXOpen::Layout *>(workPart->Layouts()->FindObject("L1"))); 24 NXOpen::ModelingView *modelingView1(dynamic_cast<NXOpen::ModelingView *>(workPart->ModelingViews()->FindObject("Back"))); 25 layout1->ReplaceView(workPart->ModelingViews()->WorkView(), modelingView1, true); 26 27 //旋转视图 28 double axis[3] = { 0.0, 0.0, 1.0 }; 29 UF_VIEW_rotate_view(BackTag, axis, 90.0, 1); 30 31 //新建视图View1 32 NXOpen::ModelingView *modelingView11(dynamic_cast<NXOpen::ModelingView *>(workPart->ModelingViews()->FindObject("Back"))); 33 NXOpen::View *view1; 34 view1 = workPart->Views()->SaveAsPreservingCase(modelingView11, "View1", true, false); 35 36 UF_terminate();