Cad Cam Development

How to retrieve user selected curve’s point coordinates using C and NX Open

The video shows the result of NX customization code that I wrote and is the problem of this post. You can select any given curve and retrieve its points in world coordinates. These may be helpful once you want to get data of projected curve, as it is shown in the video, and want to perform further operations on it. The code is very simple, short and provides a nice customer feedback. Points are sampled relatively densely so that the points wouldn’t lost information about curvatures.

Source code is downloadable from here

The main function that retrieves the curve data and prints it out to the UGS information window. To get the full project download source code from link above:

static void do_ugopen_api(void)
 char *message = "Select Spline";
 char buffer[UF_UI_MAX_STRING_LEN];
 UF_UI_selection_options_t opts;
 UF_UI_mask_t mask = {UF_spline_type,0, 0};
 int response, count;
 tag_p_t objects;
 int i,j;
 int off = 0;
 int slope;
 int curve;
 int degree;
 int periodicity;
 int num_points;
 double *parameters;
 UF_CURVE_pt_slope_crvatr_t *point_data;

 opts.other_options = 0;
 opts.reserved = NULL;
 opts.num_mask_triples = 1;
 opts.mask_triples = &mask;

 if(!UF_CALL(UF_UI_select_by_class( message,&opts,&response,
 &count,&objects )))
 sprintf(buffer,"response= %d, object count= %d\n",response,count);

 if (objects != NULL)
 for (j=0; j < count; j++)

 double ctol = 0.07612046748871;
 double atol = 0.0;
 double stol = 0.76536686473018;
 double *pts;
 int numpts;
 int index = 0;

 if(UF_CALL(UF_MODL_ask_curve_points(objects[j],ctol,atol,stol,&numpts, &pts)))
 /* Print the error message from UF_CALL macro */
 sprintf(buffer,"\nThere a no points on a curve :-(\n");
 sprintf(buffer,"\nThere are %d points on a curve :-)",numpts);

 for(i = 0; i < numpts; i++)
 sprintf(buffer,"\n%i %f %f %f",i,pts[index++],pts[index++],pts[index++]);




Trackbacks & Pingbacks


  1. * Rob says:

    The link is not working, error says file not found. Interesting stuff would like to see more NX Open examples.


    | Reply Posted 6 years, 6 months ago
    • * Grzegorz says:

      Hi Rob! Thank you for writing. The broken link problem has been resolved. You can download source code from the link. There will be more samples on days as I finally complete my studies projects.

      | Reply Posted 6 years, 6 months ago
  2. * nestorvb says:

    Hi there, the link is broken again :S any chance of sending it to me via email please?

    | Reply Posted 5 years, 6 months ago
    • * Grzegorz says:

      The same file?

      I will send you tomorrow.

      | Reply Posted 5 years, 5 months ago
      • * Eric says:

        Hi, this was a really nice video. Just this kind prorgram I am in need of now, the link seems to be broken again, any chance you can send it to me to via email too?

        Would really appreciate it

        Posted 4 years, 11 months ago
  3. * Nowis says:

    Hi Grzegorz,

    the link is broken again, is ist possible so send me the project via mail?

    Many Thanks in advance!

    | Reply Posted 4 years, 4 months ago

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s