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 4584 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 / F" ]7 Z* V- e  T9 q
6 i9 O( [0 _! l& R% G- D; a
(see PDF in the ZIP file for a pictorial description)
& \: ]; N; K6 Q$ \+ r% s
( m& I% l& ^9 \8 e" d5 x; DInstallation of Java and Eclipse
8 k' b: g2 U0 O! S5 d; n" I4 e& B0 m& m/ ~( r3 K  l
1)5 K+ }9 N6 r2 i
Download and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from0 o& l; m) P: e  t8 h+ g8 O, d
http://www.oracle.com/technetwor ... ownloads/index.html
/ J7 E4 @  P# H5 Y. m$ J' E" y2 H# }$ L. Y4 H4 x% n0 C
2): ^% b* y. l" o, F8 O* J, |  @. U
Download the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads 5 E& {% e$ ?# Q! d
and extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”
9 J! \7 V1 o+ D" D* J- o  `0 r4 e+ ~
+ h1 E6 P9 n9 A8 r' H  Y6 F) X, h7 b9 j( K
Create a project with Eclipse   
$ r+ z8 n3 h9 o( R
/ @8 }8 @+ P3 Y( k/ b) K5 P0 U$ x3)
, g; `# M& Y, N4 xStart the Eclipse IDE, for example “d:\eclipse\eclipse.exe”- ~1 N! S( n- O/ f6 U) J$ ~/ A

' ^- y3 l+ T1 u* r# x" {, I# B2 Z1 q4)
9 O$ _4 r9 G- g% f4 DYou will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio
( f4 K2 B- N4 h! M9 H- S, R  d) C9 n" @& n  P9 o: x7 o
5)
5 c: B& V1 ~# Y! GCreate a new Java Project by File -> New -> Java Project
& c0 J; O" N9 I9 |: C6 g
" N. U* ]8 A) z& u1 M9 J. V2 H6), k' t* i  Z; E9 V" |3 p
Enter a project name and continue with Next
: c; Z( I3 V( X$ S9 C, v; ?9 }. h9 d( \9 r1 [8 G+ t
7) 2 Q4 R; n+ A& ]3 j
On the Libraries Tab add the external NXOpen Jar packages and Finish
9 j/ V/ W+ d( _1 S5 T
2 }7 a; |, b/ B5 x* v8)
8 Q% `# x6 L/ i& |. MIn the Package Explorer window make a right click on the project name and create a new Package (Namespace)  
& K( z: {( X+ K  n( {
2 [" h/ ~7 ?% F- N# _5 X- ]3 A% I9) 0 H% `  A2 q3 o
Enter a package name and Finish9 a* R! O: \+ D& w: ]! O2 X

4 e9 n* }; ]: n6 j/ Y" O! u* V. B10)
( F! F! P2 h, EIn the Package Explorer window make a right click on the Package name and create a new Class    2 w3 y+ ^  I$ f

+ l+ E: m9 M" g& h; f6 h11)
% K7 S4 x, F6 H# wEnter a Class name and uncheck all method stubs options. P- K6 w. [0 B6 X1 z
6 ?: Q/ t6 G, h+ O
12)
: J& p9 W6 ^5 L7 J7 B6 k& G# LNow 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.. t4 r. f: }# F* q6 u
First we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java
2 T9 }  z! g( P8 u: H
- h% ]6 a! I* a. x3 k13)6 q$ ^' q7 ^0 W( z2 N8 Q. g
Start Recording by Tools -> Journal -> Record8 G1 h/ Q* u# C* u. L: _

2 u# {0 _: T  q" W9 w14)
4 A; @' _6 i) F: U+ a, b  ACreate a Block and finish the journal by Tools -> Journal -> Stop Recording
: x. V4 Q6 X# S! k$ U5 r4 B4 N2 ^
15). {3 d% c, H/ x
Open the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file
. F# X+ F2 L  @6 g! n1 ]9 T. I; w1 A0 x& n5 d7 [
16)8 L" N7 _- c9 j$ Y- Z& Z
Make a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”# n# {; k' m+ z2 M; n6 i" h

0 {4 a" a4 G. S- N5 b/ Z7 a1 @17)
( s, W# b( }2 |. i7 ZFinally we create the Jar file which is mandatory in case our package contains more than one class.
5 j$ a4 s' Q- [" @; O4 s6 A5 t& G- p6 FIn the Package Explorer right click on the project name and select Export -> JAR file -> Next# h2 k& j$ s3 F9 K
# O* h; u& f5 H% w+ L
18)& g& n& p+ q' w
Select the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.
: o0 q% M- {: B2 d% n/ k' z7 D
) b. p( s4 @: t' U# W, U19)" i4 o( [8 I" x' e3 E8 V5 p7 v
Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish
7 q8 a/ ?' N5 m  n0 \% K) ~/ b9 [4 ~" E; Y
4 _+ C3 Y2 S+ V; p
Debug the JAR or CLASS file with NX and Eclipse
5 Q3 k# L. {0 r/ E
3 m$ J7 M6 R; c% ]# C% y20)
& t8 |$ R1 i  ]4 ?# kIf 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 .( }4 e/ Z" b2 h& |9 H) t: G$ e
Due 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./ _2 X6 p: c* i
In 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.
5 @: L) R' a, \& Z/ J2 |  |From a NX8 command prompt, we enter the following commands:/ P7 T! F$ S' x; p  w

* o% [6 M$ D, i6 Z: o) p>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
- Z0 M8 A2 s2 {/ J) E>ugraf.exe
  X+ T4 v0 G8 |+ q8 g% y( M+ t
& O9 ^6 R3 P  T. v7 h2 zThen we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.
' k, e2 `# j0 Z4 E8 K! a2 T: ?Any simple class will do the job, for example a famous HelloWorld class.- _; Y/ {. S, y4 h
( V; E  G# ], ]: i6 {/ ?6 Y
21)- Y* s7 p) [5 d  e& A( I) U
Create the external access to the JVM session in Eclipse by Run -> Debug Configuration.: x4 t& \+ h  _5 C( X9 g
On the Remote Java Application node make a right click and select New / f2 K; t! k# P' N+ R2 J+ B: c/ U
; l7 c" A- p' o  r) L# z
22)
! r# C/ L, y% aEnter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS" U, l# n6 G. y' T% V1 `

/ q( `2 Q  H' _" m' }3 M. V6 q% V23)+ Q# m' }+ r/ v; N% M  z
Don’t forget to set one or more breakpoints in your code where you want to interrupt execution
/ z' I$ E: S* [4 p, f# n/ V5 w' F) f0 m; D9 t  a
24)+ }7 B8 ?8 \1 N0 Z0 w
Finally execute the JAR file or CLASS file in NX that you want to debug.
& s) z% ?* [4 t4 l* Q& f0 P7 ^Once the breakpoint is hit, switch to the Eclipse application, confirm to change to the Debug Perspective View and Step through your code as desired.  _9 Q! u# t( G8 y+ S1 v

" k0 o- `" C8 P+ }* T# M1 `) pThat's it.
; j# j- S$ U% h& W
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了