NX Programming Net
NX Programming Net
NX Programming Net
http://conference.et.byu.edu/~me578/578_shared/NX/1_Intro/Resource...
1 of 3
http://conference.et.byu.edu/~me578/578_shared/NX/1_Intro/Resource...
Add an entry for "%UGII_ROOT_DIR%\ugopen" to the directory list using the proper expansion for the "UGII_ROOT_DIR" environment variable (e.g. C:\ugs160\ugopen). o Use the arrow icon buttons to move the ugopen directory above all other directories. o Click the "OK" button. o
Setup
Step 1 Determine the location of the NX4 executable ugraf.exe. o Go to the Windows "Start" menu and select "Settings->Control Panel". Double-click the "System" icon. Click the "Environment" tab on the resulting "System Properties" dialog. In the "System Variables" list scroll down until you find a variable named "UGII_ROOT_DIR". The value associated with this variable is the directory path to the "ugraf.exe" executable. Select the "UGII_ROOT_DIR" variable. Highlight the complete path in the "Value" field at the bottom of the dialog and copy it to the clipboard. Step 2 Associate the NX4 executable with your project. o From within Visual C++, select the "Project->Settings" menu item and select the "Debug" tab on the resulting "Project Settings" dialog. Notice that the "Executable for debug session:" field is empty. Place the cursor in this field and then type or paste the path determined in the first step, followed by "\ugraf.exe". For example, if the value of "UGII_ROOT_DIR" were "C:\Program Files\UGS\NX4.0\ugii" then you would enter: C:\Program Files\UGS\NX4.0\ugii\ugraf.exe. You may also browse for the executable file by clicking the arrow button to the right of the "Executable for debug session:" field. Step 3 Run the Application o Click "OK" in the "Project Settings" dialog and then run or debug the application as you would normally from Visual C++. NX4 is started each time the project is executed. You are free to place breakpoints in your NX4 Open application just as you would in any other application. It may take a few moments for NX4 to appear because Visual C++ is searching for debug symbols in the NX4 DLLs, so be patient.
Print statements
Since NX4 is a native Windows application, there is no console started up automatically. Therefore using a printf to print to stdout will not work. If you want to use printf or cout statements to debug your internal NX4 Open application, you must add the following code to your internal UG/Open API function: This will create a console window and attach it to stdout so that printf and cout will work.
Known issues
When using NX4 Open, you should not make an MFC extension DLL in debug mode. This is a well known problem with Microsoft compilers. Microsoft uses different libraries for debug and release configurations. NX4 will use a release .dll, and so NX4 Open will allocate memory using the heap in that library. The customer MFC extension DLL in debug mode will use a debug library, and try to free memory using the debug library. The only work around is to either only build a release configuration, or only build as a WIN32 DLL using the NX4 Open AppWizard.
2 of 3
2010/8/4 08:38
http://conference.et.byu.edu/~me578/578_shared/NX/1_Intro/Resource...
3 of 3
2010/8/4 08:38