【NX二次开发】获取曲线上某个位置的点坐标、切线矢量、主法线矢量、副法线矢量。UF_MODL_ask_curve_props
效果:
源码:
tag_t tagCurve = vecObj[0]->Tag(); double ctol(0.0); double atol(0.0); double stol(1.0);//步进公差 int numpts(0); tag_t pt_tag(NULL_TAG); double *ufPts = NULL; UF_MODL_ask_curve_points(tagCurve, ctol, atol, stol, &numpts, &ufPts); double adTempPoint[3] = { 0.0,0.0,0.0 }; for (int i = 0; i < (numpts - 1); i++) { adTempPoint[0] = ufPts[0 + i * 3]; adTempPoint[1] = ufPts[1 + i * 3]; adTempPoint[2] = ufPts[2 + i * 3]; double curve_point[3] = { 0,0,0 }; double parm1 = 0; UF_MODL_ask_curve_parm(tagCurve, adTempPoint, &parm1, curve_point); double face_pnt[3] = { 0,0,0 }; double tangent[3] = { 0,0,0 }; //切线矢量 double p_norm[3] = { 0,0,0 }; //主法线 double b_norm[3] = { 0,0,0 }; //副法线 double torsion; double rad_of_cur; UF_MODL_ask_curve_props(tagCurve, parm1, adTempPoint, tangent,
p_norm, b_norm, &torsion, &rad_of_cur); UF_CURVE_line_t lineP; UF_VEC3_copy(adTempPoint, lineP.start_point); tag_t tagLine = NULL_TAG; double douLenth = 0.0; UF_VEC3_unitize(tangent, 1E-6, &douLenth, tangent); UF_VEC3_add(lineP.start_point, tangent, lineP.end_point); UF_CURVE_create_line(&lineP, &tagLine); UF_OBJ_set_color(tagLine, 186); UF_VEC3_unitize(p_norm, 1E-6, &douLenth, p_norm); UF_VEC3_add(lineP.start_point, p_norm, lineP.end_point); UF_CURVE_create_line(&lineP, &tagLine); UF_OBJ_set_color(tagLine, 108); UF_VEC3_unitize(b_norm, 1E-6, &douLenth, b_norm); UF_VEC3_add(lineP.start_point, b_norm, lineP.end_point); UF_CURVE_create_line(&lineP, &tagLine); UF_OBJ_set_color(tagLine, 6); } UF_free(ufPts); UF_terminate();