PLM之家精品课程培训,联系电话:18301858168 QQ: 939801026

  • NX二次开培训

    NX二次开培训

    适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术对于老鸟也值得借鉴!.

    NX CAM二次开发培训报名 NX二次开发基础培训报名
  • PLM之家Catia CAA二次开发培训

    Catia二次开发培训

    Catia二次开发的市场大,这方面开发人才少,难度大。所以只要你掌握了开发,那么潜力巨大,随着时间的积累,你必将有所用武之地!

  • PLM之Teamcenter最佳学习方案

    Teamcenter培训

    用户应用基础培训,管理员基础培训,管理员高级培训,二次开发培训应有尽有,只要你感兴趣肯学习,专业多年经验大师级打造!

  • PLM之Tecnomatix制造领域培训

    Tecnomatix培训

    想了解制造领域数字化吗?想了解工厂,生产线设计吗?数字化双胞胎,工业4.0吗?我们的课程虚位以待!

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

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

[复制链接]

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

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

admin 楼主

2014-5-9 16:14:24

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

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

x
1 i& m5 t# A8 u: ~! H: n+ ^% Q# B
- i, t2 M6 f6 t+ e% Y
  I% c$ Z, F# K& k% i' B
DebUGging and Running
3 r, e; U- z; G3 K$ D5 Q# D, u  
' a9 Q3 ?* H: R 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). , P. X2 s. {# d4 u/ s) |
  
$ T: l" P* t* ]1 ]* u Step 1 Determine the location of the NX executable ugraf.exe. ! b. A# z/ L* b4 G3 d. M" k
  & s4 P4 _( D! N9 G, [! n
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.
; y* F' k; ?8 x3 P# v- l2 z% E  
1 E3 N% f9 C; |, l Step 2 Associate the NX executable with your project.
( Q- a; x0 c9 x+ z  
0 |: o7 \% P0 }0 E+ k  l* z 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. 0 ~/ D0 j6 R' l5 z/ ]* e1 _
  
9 w5 x4 }' V, N/ e Step 3 Set the working directory. $ M8 s6 o+ f3 D, U/ j7 N
  
& l- t  U8 z* O/ ^% @; i 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.
) ?' t1 [3 N& a2 w' D( c  9 ?. x  Y3 z5 s  K
Step 4 Set the NX program arguments (optional) 8 L8 F. b* l4 J8 n' a& f: \9 D
  8 Q5 X' P/ N+ e+ G& ^) Y" x
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. 6 l( _! L" ?4 m) Q( U. K( y
  / k5 @2 P  r! F! g7 P+ G( X
Step 6 Run the Application
- u. V! H; o% O- n) A: \* o% i  & P/ V/ _; q$ k* ^- G! A
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.
. C, v" L) G: {  
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:
# v8 }# T! j0 u7 b0 l( G  
; q( T- C5 @  L; U: C #include <windows.h>: b) b5 }' [" F5 I6 K
#include <fstream.h>. ]8 s" D' T' {
#include <stdio.h>
+ D+ @/ y9 @& x- s6 }6 t+ Z/ O7 _ ...% {# G6 w! |* J, i# ?
FILE *fp;
$ v. D% }/ u2 a ...  R1 \! D& M" k5 I* z7 U; N4 i+ y
0 W0 ?* z: I3 x% F8 u. |+ `6 N
/* allocate console window conout$ */0 Z0 b+ d0 u. ^2 s: q6 B
AllocConsole();/ w8 I/ h0 ~: c
/* reopen stdout on conout$ for fprintf and printf */
. z5 S: I* i* kfp = freopen("conout$", "w", stdout); , t  H+ Y$ V4 N1 E
  ( }+ ]8 r! j/ Q. M7 P
This will create a console window and attach it to stdout so that printf and fprintf will work. 2 l% _% \" o4 U( R1 n; Q% d4 R
  

) c$ V# ~8 x3 H+ l( t3 K/ R
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了