Cad Cam Development

How to get properties of points in NX Open

Matthew asked me for help by posting a comment on about page and I helped him solving. This post is a response for his comment, presents nice real-world CFD problem and general discussion about journal reliability and usability.


I am trying to write a code in C++ to automate NX. I can`t find out how to do one thing:

I have few points in NX and a surface (points do not belong to surface). I projected this points using C++ code. The problem is that I need coordinates data of projected points and I don`t know how to get this data.
My purpose is to get coordinates of this projected points and save them in .txt file.

I would be very grateful if You could help me.

best regards


What actually Matthew did?

He recorded a session using Journal and then he was with almost all work done except one: getting the coordinates of projected points at the las stage and saving to external file. It was impossible to get it from journal.  The solution was quite simple. it took me a few lines to solve:

The original piece of code:

Point *point2;
 point2 = workPart->Points()->CreatePoint(point1, nullXform, SmartObject::UpdateOptionWithinModeling);



NXObject *nXObject1
 nXObject1 = projectCurveBuilder1->Commit();
catch(const NXException & ex)

What I added to that part of code is:

NXObject *nXObject1;
 nXObject1 = projectCurveBuilder1->Commit();
 Point3d p = point2->Coordinates();

//output = file that goes output to
 output<<p.X<<" "<<p.Y<<" "<<p.Z<<std::endl;

//display info to NX information window
 catch (const NXException &ex)
 k = 1;

What was it used for? Matthew used projected points to perform CFD computations so that an airfoil could be optimized. He got some unoriented points, crated a curve and projected it onto airfoil, some planar surface and some part of wing surface. Then he wanted to get the coordinates of those projected points to proceed with further work.

Airfoil 1

General airfoil image

Bear it in mind that journal does not record everything you click in the UI, produces a bit more code that is required to solve problem and won’t handle geometrical properties like you would have done it manually. So journal could be good start point but in order to get well-written NX customization code you have to write code and clean meticulously journal file after recording session. There is another limitation of journal. You cannot save journal files in plain C, this means, journal does not record in the oldest NX automation api. You can save .NET, Java, C++ but everything will be in the relatively new one NX Open API. The oldest C API is widely used. So in case are you going to modify existing code, you have to adhere to the rules. The C API derives from 1997 and is very well written, quite easy to use and versatile. There are tons of documented functions which help in development. Using NX Open you get access to almost every feature NX offers, so you are not limited. To summon up: either program in C and old good API or C# with a bit newer API, that in fact resembles its elder brother and is packed in objects. The main ideas of getting properties, managing geometries are almost the same. Suppose you know .NET and C#, if you were writing in C NX then it wouldn’t hurt you to write C# NX.


Trackbacks & Pingbacks


  1. * Rob says:

    Nice article!

    | Reply Posted 5 years, 11 months ago
  2. * tay says:

    Thanks for that tutorial. I just started using NX6 and found the website to have many interesting articles, tutorials, and models. I hope you find it helpful also!

    | Reply Posted 5 years, 8 months ago
  3. * Carlo Tony Daristotile says:

    My code fails at the end when the function coordinates is called.

    if mySelObj.GetType.ToString=”NXOpen.Routing.ExtractPort” then
    Dim routingExtractPort as NXOpen.Routing.ExtractPort = mySelObj

    Dim routingExtractPoint3D as NXOpen.Point3D
    routingExtractPoint3D = routingExtractPort.Position()

    Dim stockOffsetPoint as NXOpen.Point
    stockOffsetPoint = routingExtractPort.GetStockOffsetPoint()

    Dim stockOffsetPoint3D as NXOpen.Point3D
    stockOffsetPoint3D = stockOffsetPoint.coordinates()

    end if

    | Reply Posted 4 years 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