NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码
NX 二次开发中创建曲线命令及获取点,线,圆弧信息源码<p>static void do_ugopenapi()
{
/*
Create Curve
*/
// create line
UF_CURVE_line_t line_coords;
tag_t line;
line_coords.start_point=0;
line_coords.start_point=0;
line_coords.start_point=0;
line_coords.end_point=100;
line_coords.end_point=100;
line_coords.end_point=100;
UF_CURVE_create_line(&line_coords,&line);</p><p> //create arc
UF_CURVE_arc_t arc_coords;
tag_t arc,marix,wcs;
UF_CSYS_ask_wcs(&wcs);
UF_CSYS_ask_matrix_of_object(wcs,&marix);
arc_coords.arc_center=0;
arc_coords.arc_center=0;
arc_coords.arc_center=0;
arc_coords.start_angle=90*DEGRA;
arc_coords.end_angle=270*DEGRA;
arc_coords.radius=100;
arc_coords.matrix_tag=marix;
UF_CURVE_create_arc(&arc_coords,&arc);
// create point
double point_coords={100,100,100};
tag_t point;
UF_CURVE_create_point(point_coords,&point);
// create Plane
double origin_point={100,100,100};
double plane_normal={1,0,0};
tag_t plane_tag;
UF_MODL_create_plane(origin_point,plane_normal,&plane_tag);</p><p> /*
Get the curve information
*/
UF_UI_open_listing_window();
char msg;
// get line information
UF_CURVE_line_t line_info;
UF_CURVE_ask_line_data(line,&line_info);
sprintf(msg,"line coords:\n\t%lf,%lf,%lf;\n\t%lf,%lf,%lf",line_info.start_point,
line_info.start_point,line_info.start_point,line_info.end_point,line_info.end_point,
line_info.end_point);
UF_UI_write_listing_window(msg);
//get the point information
double point_info;
UF_CURVE_ask_point_data(point,point_info);
sprintf(msg,"\npoint coords:\n\t%lf,%lf,%lf",point_info,point_info,point_info);
UF_UI_write_listing_window(msg);</p><p> //get the arc information
UF_CURVE_arc_t arc_info;
UF_CURVE_ask_arc_data(arc,&arc_info);
sprintf(msg,"\nArc Center coords:\n\t%lf,%lf,%lf;\nArc start Angle:\n\t%lf;\nArc End Angle:\n\t%lf;\nArc Radius:\n\t%lf;",
arc_info.arc_center,arc_info.arc_center,arc_info.arc_center,
arc_info.start_angle*RADEG,arc_info.end_angle*RADEG,arc_info.radius
);
UF_UI_write_listing_window(msg);
// calculate the arc length
double arc_length;
UF_CURVE_ask_arc_length(arc,0,1,UF_MODL_UNITS_PART,&arc_length);
sprintf(msg,"\nArc Length:\n\t%lf",arc_length);
UF_UI_write_listing_window(msg);
}
</p><p> </p>
页:
[1]