NX secondary development -UFUN get projected curve in the curve UF_CURVE_ask_proj_curves

  1 NX11+VS2013
  2 
  3 #include <uf.h>
  4 #include <uf_modl.h>
  5 #include <uf_curve.h>
  6 #include <uf_obj.h>
  7 
  8 
  9 
 10     
 11 UF_initialize();
 12 
 13 //创建四条直线
 14 UF_CURVE_line_t Line_coords1;
 15 Line_coords1.start_point[0] = 0.0;
 16 Line_coords1.start_point[1] = 0.0;
 17 Line_coords1.start_point[2] = 0.0; 18 Line_coords1.end_point[0] = 10.0; 19 Line_coords1.end_point[1] = 0.0; 20 Line_coords1.end_point[2] = 0.0; 21 tag_t LineTag[4]; 22 UF_CURVE_create_line(&Line_coords1, &LineTag[0]); 23 24 UF_CURVE_line_t Line_coords2; 25 Line_coords2.start_point[0] = 10.0; 26 Line_coords2.start_point[1] = 0.0; 27 Line_coords2.start_point[2] = 0.0; 28 Line_coords2.end_point[0] = 10.0; 29 Line_coords2.end_point[1] = 10.0; 30 Line_coords2.end_point[2] = 0.0; 31 UF_CURVE_create_line(&Line_coords2, &LineTag[1]); 32 33 UF_CURVE_line_t Line_coords3; 34 Line_coords3.start_point[0] = 10.0; 35 Line_coords3.start_point[1] = 10.0; 36 Line_coords3.start_point[2] = 0.0; 37 Line_coords3.end_point[0] = 0.0; 38 Line_coords3.end_point[1] = 10.0; 39 Line_coords3.end_point[2] = 0.0; 40 UF_CURVE_create_line(&Line_coords3, &LineTag[2]); 41 42 Line_coords4 UF_CURVE_line_t; Line_coords4.start_point 43 is [0] = 0.0 ; 44 is Line_coords4.start_point [. 1] = 10.0 ; 45 Line_coords4.start_point [2] = 0.0 ; 46 is Line_coords4.end_point [0] = 0.0 ; 47 Line_coords4.end_point [. 1] 0.0 = ; 48 Line_coords4.end_point [2] = 0.0 ; 49 UF_CURVE_create_line (& Line_coords4, & LineTag [. 3 ]); // creation block 51 is 50 52 UF_FEATURE_SIGN Sign = UF_NULLSIGN; // set the Boolean 53 double Corner_pt [3] = { -50.0 , -50.0, -110.0}; // set the origin 54 char * Edge_Len [3] = { "100", "100", "100"}; // set tag_t BlkTag = LWH 55 NULL_TAG; 56 is UF_MODL_create_block1 (Sign , Corner_pt, Edge_Len, & BlkTag); characterized in looking surface 57 is 58 // 59 uf_list_p_t faceList; 60 UF_MODL_ask_feat_faces (BlkTag, & faceList);61 62 // get the list of the number 63 int count = 0; 64 UF_MODL_ask_list_count (faceList, & COUNT); 65 = 66 tag_t redFaceTag NULL_TAG; 67 for (int I = 0; I <COUNT; I ++ ) 68 {69 // Get each linked list 70 tag_t faceTag = Tag NULL_TAG; 71 is UF_MODL_ask_list_item (faceList, I, & faceTag); 72 // 73 is obtained int origin of each face 74 the Type; 75 Double Point [. 3 ]; 76 Double the Dir [. 3 ]; 77 Double Box [. 6 ]; 78 Double the Radius [. 3 ]; 79 Double RadData [. 3 ]; 80 int NormDir; 81 UF_MODL_ask_face_data (faceTag, & the Type, Point, the Dir, Box, the Radius, RadData, & NormDir); surface 8283 // find the distance 10 (the top surface of the block) IF 84 (FABS (FABS (Point [2]) - 10) <from 0.001 ) 85 {86 // set the color UF_OBJ_set_color 87 (faceTag, 186 ); 88 redFaceTag = faceTag; 89 } 90} // create a curve 91 92 93 list 94 uf_list_p_t curve_refs; 95 UF_MODL_create_list (& curve_refs); 96 // add objects to the list 97 uf_list_p_t face1_refs; 98 for (int I = 0; I <. 4; I ++ ) 99 {100 UF_MODL_put_list_item (curve_refs, LineTag [I]); 101 } 102 103 // create a surface UF_MODL_create_list list 104 (& face1_refs); 105 UF_MODL_put_list_item (face1_refs, redFaceTag); 106 107 108 // Create projection curve 109 int along_face = 0; // 0 using a projection vector = (proj_vector), 1 = use the surface normal 110 double proj_vector [3] = { 0.0, 0.0, -1.0}; // projected vector direction tag_t proj1tag = 111 NULL_TAG; 112 UF_MODL_create_proj_curves (curve_refs, face1_refs, along_face , proj_vector, & proj1tag); 113 // 114 115 // Get method of projection curve 1116 in graph 117 uf_list_p_t uf_curve_refs; 1 18 UF_MODL_ask_proj_curves (proj1tag, &uf_curve_refs); 119 120 // get the list of the number of curveCount int = 0 121 ; 122 UF_MODL_ask_list_count (uf_curve_refs, & curveCount); 123 124 for (int I = 0; I <curveCount; I ++ ) 125 {126 // list acquired in the each tag_t curveTag = 127 Tag NULL_TAG; 128 UF_MODL_ask_list_item (uf_curve_refs, I, & curveTag); // set the color 129 130. UF_OBJ_set_color 131 is (curveTag, 136 ); 132 } 133 134 method //// 2 135 // int n_curve_refs = 0; 136 // tag_t * curve_refsTag = NULL_TAG; 137 // UF_CURVE_ask_proj_curves (proj1tag, & n_curve_refs, & curve_refsTag); 138 139 // for (int i = 0; i <n_curve_refs; i ++) 140 // {141 // // set color 142 // UF_OBJ_set_color (curve_refsTag [i] , 136); 143 //} 144 145 // delete the list UF_MODL_delete_list 146 (& uf_curve_refs); UF_MODL_delete_list 147 (&curve_refs); 148 UF_MODL_delete_list(&face1_refs); 149 UF_MODL_delete_list(&faceList); 150 151 UF_terminate(); 152 153 caesar卢尚宇 154 2020年2月29日

Guess you like

Origin www.cnblogs.com/nxopen2018/p/12387306.html