PLM之家PLMHome-国产软件践行者

[资料] UG NX 二次开发 调试 debug的使用步骤

[复制链接]

2014-5-9 16:14:24 4045 0

admin 发表于 2014-5-9 16:14:24 |阅读模式

admin 楼主

2014-5-9 16:14:24

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
0 U7 ^4 a! _0 q

6 f8 x  `5 v3 M* c  D* |. u
6 A7 Z9 N* l1 U7 _# b; L5 ~, T
DebUGging and Running
4 n$ G. G0 r6 H  
: R+ w- A' m1 j. h If the project is an internal Open C application (DLL), the following steps must be performed to associate the NX executable with the project. If these steps are not performed, the application cannot be executed or debugged from the Visual C++ environment. These steps do not apply to external Open C applications (EXEs). & Y+ v! e& a& o4 q, J2 y3 x
  : f- ~2 s/ P$ V7 G
Step 1 Determine the location of the NX executable ugraf.exe. : \- C" K" L4 p6 _* t- S. r1 w
  7 V1 s9 T2 w( m6 T9 b
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. 0 q8 u8 U. J4 I1 u3 h
  
! H, F. R4 p8 G* Q( J3 b Step 2 Associate the NX executable with your project.
' I: s( A; s  T/ }% `  3 A5 J# x$ m) r' S1 _/ e$ 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:\ugnx50\ugii" then you would enter: C:\ugnx50\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.
7 M  w; ~- H1 c) S7 k3 n  . Z; r- T9 z* v8 w0 ^! \
Step 3 Set the working directory. & N" q; |+ p; L  n! M
  
/ k  H! t3 n, A: u6 z! C The "Working directory:" field on the "Project Settings" dialog specifies the directory from which Visual C++ runs NX. A common convention is to use "C:\TEMP" for the working directory.
' ^# L  U: X' Z, p! l7 G( w; I9 D  1 e: q. V$ p3 N5 J/ K0 b$ l# i: h. E
Step 4 Set the NX program arguments (optional) # M1 a6 ^8 S. f
  
6 z7 D% r) b1 @ You may set any NX program arguments you require by entering them in the "Program arguments:" field on the "Project Settings" dialog. The syntax is exactly the same as the command-line syntax for starting NX.
) a7 s, A& ~% D7 G  K2 F* k  z/ s  2 s0 W# e5 A' J) {, g( z, C
Step 6 Run the Application
0 M$ {1 I" z! n! V3 h  
+ Y& z2 K6 z5 u* y9 n2 ?) i Click "OK" in the "Project Settings" dialog and then run or debug the application as you would normally from Visual C++. NX is started each time the project is executed. You are free to place breakpoints in your Open C application just as you would in any other application. It may take a few moments for NX to appear because Visual C++ is searching for debug symbols in the NX DLLs, so be patient.
) S% S6 ^+ S& X& `" X  
Print statements
Since NX 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 statements to debug your internal Open C application, you must add the following code to your internal Open C API function:
3 E' A  g% F0 [! x5 {2 K! }& u8 L  
4 h# |! d  `$ l8 ^7 a* U! { #include <windows.h>
0 j7 R) n8 s; g  B6 c( B0 J: P, X #include <fstream.h>
5 H1 C- x% @' R' v2 z2 N$ P& R #include <stdio.h>
8 m3 s; b6 O* K; W( W4 r ...
" z. U8 e, F. y* W* y FILE *fp;
: E6 O- _2 W: o; O( q. Q ...+ r: ^" R! m; w8 |' U* o" }3 A/ m
1 p- K  O6 f1 i
/* allocate console window conout$ */
: q, F8 R, a7 U4 R" BAllocConsole();
4 t$ p6 g! {2 G' v6 g /* reopen stdout on conout$ for fprintf and printf */
; f6 n* B% m8 H1 |$ yfp = freopen("conout$", "w", stdout);
$ C! E! ^7 Z7 n$ s  ( |8 Z1 q2 ?+ P, \# L! x
This will create a console window and attach it to stdout so that printf and fprintf will work.
* _# q0 n3 h" B- ]' y5 s9 H+ B  

6 G) o  |. k% Y) B* H$ K0 H" ]
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了