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 3862 0

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

admin 楼主

2014-5-9 16:14:24

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

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

x
; k) s8 n5 I( W4 M+ n7 w2 J* b6 b* {
, q* Z# z5 k/ a# W+ v- Y8 N

4 s' q- u) J) n: N
DebUGging and Running
, L' t6 G+ \/ ~* N  
' i+ B; @. P' B* ^ 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).
- x3 I+ J8 L+ @# p. w- M& f3 B3 V  7 Y' ^6 Y. r* h( G( i9 Q9 b
Step 1 Determine the location of the NX executable ugraf.exe. 8 z2 R: L4 e; k: @
  
- J2 |, P' p3 B6 R3 E' ` 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. + T  ~5 R, M" Y0 g
  
# L* J/ G& b  ?. W Step 2 Associate the NX executable with your project. : ~! ~' ?- d' v6 {8 x: O) D
  ) T$ z% r. b$ u4 X; Y% R7 O2 B
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. : N+ t2 y# Z( U) T
  
$ U# }7 }- c4 E/ ~# p0 H+ v Step 3 Set the working directory.
8 {/ r/ ?$ @" u* K0 J. t  
+ C/ Q6 ?" S2 ~4 e 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. : k0 @7 G+ b. x, `7 m
  ) B4 k& `  H7 T( Z. T% y- @
Step 4 Set the NX program arguments (optional)
! b. a9 M( ^, j  - z8 P( e& Q/ p: E) x3 }
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.
+ l# N5 f- B+ U# |6 C4 J  
- m, o3 d$ Z% ] Step 6 Run the Application
5 t$ l6 F# l; e$ L5 J% ^) J9 ?2 I  h  
( }3 W# U- e  j% `, _ 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.
! Y: X# J% m. r/ v, c  
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: ) c5 a1 ~% X6 Q# z8 E
  
6 `8 J0 ]& w5 k. ] #include <windows.h>
# m2 q. @% g2 }1 v. D #include <fstream.h>
) v0 M9 V9 R8 Y; i5 T! G #include <stdio.h>8 ?% R# T3 B4 K- O7 }
..." G- z5 H4 R  `6 B# H$ A$ w) I9 O( F
FILE *fp;
; p" \5 A7 _0 f% S ...) U+ Q& {8 W. }( {
! r/ c* ?. s5 `1 B: z' y
/* allocate console window conout$ */5 I: f% g  }  E& }2 I& v; ~$ v
AllocConsole();
0 C, c! s" x. e% S; I/ b/ P6 ~ /* reopen stdout on conout$ for fprintf and printf */
5 L4 a" {$ I' F  l4 Lfp = freopen("conout$", "w", stdout);   [# [- w, ~4 D) f. o* _
  
& P- U. O5 h* O/ k9 U$ i3 q' G3 } This will create a console window and attach it to stdout so that printf and fprintf will work.
1 l2 m- {8 Z% L  

8 M8 q, L: D, [' r6 c' Y
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了