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-国产软件践行者

[原创] 使用eclipse进行NX二次开发的设置步骤

[复制链接]

2015-2-25 13:02:01 4449 0

admin 发表于 2015-2-25 13:02:01 |阅读模式

admin 楼主

2015-2-25 13:02:01

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

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

x
DebUGging NXOpen Java with NX8 and Eclipse IDE
7 M& R! [* K2 {4 }. [  D9 H
3 n( K0 i( y: ]  S& B3 t% k+ I(see PDF in the ZIP file for a pictorial description)
  H: t; w! q7 q+ h$ H
$ J( |5 u, T1 W. sInstallation of Java and Eclipse8 s  n* G& x; ?! M" J. L- B9 T5 }' R3 Y
. E1 h( g8 x7 C
1)3 J- J4 F, _: |: |+ `# E6 {
Download and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from/ F6 E7 \: O, N, u* u
http://www.oracle.com/technetwor ... ownloads/index.html
! n$ U  z1 ~  C4 ~
7 C+ ?% y3 C, v. S# j9 D2)3 u' Y7 {3 N& Y9 J# G
Download the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads : Y! x) f; w: d2 ~. @) r2 @% b
and extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”
1 A2 d' Z2 {/ @' x% C2 N* G
) G# q! g; h- [8 K! ]( M, v8 e% {2 U( l# `! m( s% B
Create a project with Eclipse   " ~  D" A* {0 G* U4 L
& [: F, ^5 ^. ^$ y1 d* q8 P
3)
& U* n+ u8 Z0 }& p2 dStart the Eclipse IDE, for example “d:\eclipse\eclipse.exe”' ?! E& d5 q2 m! v0 R2 {5 l) j

& l' V; l" z+ A: B, n4)
0 p: H. I0 Y& e" c. p% _5 Y/ qYou will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio7 `( [6 g0 f3 ?
, B0 z; ]  L$ ^+ y/ o
5)9 s# t. M+ Q6 v% z) ~0 M
Create a new Java Project by File -> New -> Java Project; W  ?6 W* {! x/ D+ s9 e) l3 n. I

* W& m3 ~' ^# q9 u( o. u6)" o% L$ @. X9 e" t
Enter a project name and continue with Next6 \; @4 a; H0 a" o5 U
& s& U0 Y% s0 C; P7 h5 T
7)
' o% O/ _, O. w" l4 [) ROn the Libraries Tab add the external NXOpen Jar packages and Finish
" f3 H' c- A% G' P4 n
' C, g2 V+ ]1 H; j+ \8)
& \; U+ k  c. U. K( oIn the Package Explorer window make a right click on the project name and create a new Package (Namespace)  
9 G. C5 ?" j, s: O0 z
" ?3 i% l5 F6 m* ]$ H5 g9)
4 C$ `5 G2 J" @) [8 H" ^" \+ r; TEnter a package name and Finish
0 Z: I* |( d4 K0 G" L$ A8 K0 |# M( `/ j( ^
10)9 W& S) U$ c" Z  f+ S- }
In the Package Explorer window make a right click on the Package name and create a new Class   
* f& F7 f9 k1 V  \7 {9 n0 E3 Z. \# M7 I; s7 X( c
11)7 |6 ~% Y1 L, N- d3 v/ |! \7 v
Enter a Class name and uncheck all method stubs options
, z9 n4 T/ j8 v2 W5 Y0 h* O. ?3 p- j8 n8 c+ T2 E
12)
. D% N; b2 N5 y9 q4 aNow you have a project created with an empty class so it’s time to complete the source code and we use the NX Journal Recording.
- a4 q1 x) |% |9 o$ |5 @; sFirst we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java( V: V+ K6 y9 J4 `3 u$ \# r8 |
/ S& [/ t7 n* P# x/ f* b
13)
9 S0 c, I+ X& k+ v% b+ tStart Recording by Tools -> Journal -> Record1 {! }' _3 d7 Z3 I6 Z
& u' ~6 z+ z1 s' Z
14)
' I+ `# e9 g0 B# g8 E7 xCreate a Block and finish the journal by Tools -> Journal -> Stop Recording
8 i4 q9 v4 |- w) D( x/ y1 I' H0 |& s" s
15)
3 K9 h6 f! i& ]# ^Open the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file. k! \0 P7 \1 f0 _

7 q5 t+ t0 V4 w16)
% y/ ?: i5 L+ J% _Make a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”
# l# g3 v; k9 M% b% R; Q; ]8 g: r* @6 V- n& d
17): l! b9 M/ \  M5 Z/ v. g
Finally we create the Jar file which is mandatory in case our package contains more than one class.+ h7 T, s9 ]& s# `6 p, V' S- n
In the Package Explorer right click on the project name and select Export -> JAR file -> Next, ?1 X5 L7 N& d0 g$ }1 m

1 t, J6 ~) t6 G% K# @18)
* o& y- @+ D  s0 [- y4 d, LSelect the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.
/ V! P# o0 L# ]0 v2 v7 F2 \: b3 U8 x1 Q4 ?  M2 v8 N: R8 Q- ~- b
19)
1 q9 h- r% E& P  R( I! ~Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish& Q( g2 Q9 m' E  O5 p
7 V7 C5 E8 x7 D

* n0 e) J4 A& o( G% w5 \4 t* hDebug the JAR or CLASS file with NX and Eclipse
# `) d$ P* j2 s" z: e6 Q, e; J( J$ s  r4 D: E7 z
20)
$ \' A# _( O4 E0 m/ r& R, xIf we want to debug a single class only, we could use the compiled Java class file which can be found automatically after saving the Java source file in workspace\projectname\bin\packagename\class .
; e. ?% R( i. S4 @( CDue to Java naming convention and limitations we don’t want to have multiple classes in one file so in that case we would use the final JAR archive file.
. h4 o% B4 ]& W7 \9 M- L# z. C+ MIn order to connect to the NX session, NX needs to start the JVM (Java Virtual Machine) along with some debug settings, for example the communication port between NX and Eclipse.
9 v1 c0 ?( E. q& E/ `From a NX8 command prompt, we enter the following commands:
3 Z& q, @3 Q$ T  D
# s' r- U3 H: n! }* v>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
7 G3 C8 Q) w) K  t) b0 [( B8 X>ugraf.exe4 n2 i& h' C4 C$ H7 X
4 D/ S1 E. G4 {+ B- N1 Y# G+ t' P8 ]2 P) W
Then we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.
  A2 x5 m1 x: p# Q0 CAny simple class will do the job, for example a famous HelloWorld class.
* m  Q3 C. r$ B1 \
) G+ u* ]& k0 M2 W21)  o8 u2 s; K* p) ~# `0 q! v# S/ N% i9 m% `
Create the external access to the JVM session in Eclipse by Run -> Debug Configuration.- I. w) \3 w# O# `# J
On the Remote Java Application node make a right click and select New
" L, s% Z5 q6 A* P8 c( o# Z' h3 ~+ J, D/ q; U
22)
' g4 R# G' q! d- bEnter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS
0 I' b) s$ j; m7 Q7 q2 V5 T5 o  H  g  A; K" W- S2 B
23)
. n) [- f8 c9 z, Q, k4 L0 v/ H8 kDon’t forget to set one or more breakpoints in your code where you want to interrupt execution
( J$ m5 B! F) ?, l, ^& ]; v. j" h2 h2 {6 C; Z! G; {  v
24)
& w% r" z! a+ B8 o) NFinally execute the JAR file or CLASS file in NX that you want to debug.
" A  m& N# n% u# A  ^4 x2 zOnce the breakpoint is hit, switch to the Eclipse application, confirm to change to the Debug Perspective View and Step through your code as desired.
6 U$ f7 b( _9 }
) U& S9 Q3 l; L9 T) l6 ]. b9 U0 vThat's it.) F* R7 g# G% R- z! _( u6 j$ y& \; T. s
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了