说明:
选择一个产品面,选择面上的点,生成点在此面上的法线反向,生成直线。
生成矢量的起点坐标,和矢量方向信息。可用于三坐标测量,如果需要可以自己编个插件用!
效果图:
源码:
//------------------------------------------------------------------------------ //Callback Name: update_cb //------------------------------------------------------------------------------ int Test003::update_cb(NXOpen::BlockStyler::UIBlock* block) { static tag_t face_tag = 0; char msg[132] = ""; try { if (block == face_select0) { //---------Enter your code here----------- std::vector<TaggedObject*>objects = face_select0->GetSelectedObjects(); //选面,得到的TAG赋给objects face_tag = objects[0]->Tag();//将C++的TAG转换成C的TAG } else if (block == point0) { //---------Enter your code here----------- double ref_pnt[3] = { 0,0,0 }; //输入一个点 Point3d originPt = this->point0->GetProperties()->GetPoint("Point"); ref_pnt[0] = originPt.X; ref_pnt[1] = originPt.Y; ref_pnt[2] = originPt.Z; double parm1[2]; double face_pnt[3] = { 0,0,0 }; UF_MODL_ask_face_parm(face_tag, ref_pnt, parm1, face_pnt); //分析点在面上U,V方向的位置 double point[3]; double u1[3]; double v1[3]; double u2[3]; double v2[3]; double unit_norm[3] = { 0.0, 0.0, 0.0 }; double radii[2]; UF_MODL_ask_face_props(face_tag, parm1, point, u1, v1, u2, v2, unit_norm, radii); unit_norm[0] = -unit_norm[0]; unit_norm[1] = -unit_norm[1]; unit_norm[2] = -unit_norm[2]; UF_UI_open_listing_window(); sprintf(msg, "起点位置: %.2f,%.2f,%.2f ", ref_pnt[0], ref_pnt[1], ref_pnt[2]); UF_UI_write_listing_window(msg); sprintf(msg, "矢量方向: %.2f,%.2f,%.2f ", unit_norm[0], unit_norm[1], unit_norm[2]); UF_UI_write_listing_window(msg); //欢迎加入二次开发QQ群:753801561 本源码仅自学请不要转载 UF_CURVE_line_t line_coords; tag_t line = 0; line_coords.start_point[0] = ref_pnt[0]; line_coords.start_point[1] = ref_pnt[1]; line_coords.start_point[2] = ref_pnt[2]; line_coords.end_point[0] = ref_pnt[0] + unit_norm[0]; line_coords.end_point[1] = ref_pnt[1] + unit_norm[1]; line_coords.end_point[2] = ref_pnt[2] + unit_norm[2]; UF_CURVE_create_line(&line_coords, &line); } } catch (exception& ex) { //---- Enter your exception handling code here ----- Test003::theUI->NXMessageBox()->Show("Block Styler", NXOpen::NXMessageBox::DialogTypeError, ex.what()); } return 0; }