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 4616 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
0 g& l" P% D& |  e* P7 r+ d4 r9 O3 }2 c  o
(see PDF in the ZIP file for a pictorial description)
  V$ H* `" y- r$ E: n  b
  k7 U4 o8 \, c- p# R8 A, z+ J' y) PInstallation of Java and Eclipse/ p! l8 B( g/ H# J7 f- Z

- `# k- \8 C. a. r5 b1)
) Z& K% z4 t  e) t* NDownload and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from
  a0 {9 _/ R9 I% Phttp://www.oracle.com/technetwor ... ownloads/index.html
4 \0 ?) [2 v) {3 j* m; i& }3 v( T, d( @; [  Y
2)
% u$ ], v' f% {Download the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads ! J3 _' H) e, ?2 x, t+ ^& J9 o6 B
and extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”
* d3 c5 A/ Q- {: G$ ]: J; O7 T8 a# f7 [
# `6 C) l0 I, H2 ]" s0 \* J* U! r
Create a project with Eclipse   1 i- y) m! S1 Y: {: U2 I

- Q: X8 t' ^; e3 h7 E. T( D/ J3 S3)9 X& y  t& G3 \* ?8 [# R0 ]1 Y
Start the Eclipse IDE, for example “d:\eclipse\eclipse.exe”+ W; W& L' P8 U) T, Q+ S4 D

2 }1 t8 i: E* i/ @" d- o3 i8 a4)' G0 d$ K* f4 b+ u8 Q  d' S1 ~
You will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio
; e" d4 S& W6 v3 {! L2 J9 M3 D
. r6 M- Y/ I* Q9 _- x5)
4 q' p: e' J3 o5 GCreate a new Java Project by File -> New -> Java Project
% F, N( \1 a$ @0 \) y4 j% X5 s4 F& F3 H9 Z$ e* v
6)
% r0 a0 M# g& g- t0 L2 a7 J! Y  EEnter a project name and continue with Next
" f  }! l1 D( p. R% g5 V( d5 E+ d
' _  h7 p6 U8 U+ V0 o7) + @7 D' f# L' C  O- I
On the Libraries Tab add the external NXOpen Jar packages and Finish
) a1 d9 ?- c+ P! Q# h% g3 B; y, {, e8 j2 [! [; B4 x
8)
4 D) ^1 W1 X: |. j; qIn the Package Explorer window make a right click on the project name and create a new Package (Namespace)  
$ u1 _" g. m- G5 i4 D( L
/ c+ m" B" U- y9) % j3 u+ C* v3 T: D/ l
Enter a package name and Finish
1 u1 }8 O- B) j5 e3 S
4 i7 k$ c# Y- {% G- G% B8 `& e% T10)7 _0 ?2 z2 X2 U0 d% a
In the Package Explorer window make a right click on the Package name and create a new Class   
) Y) r* l8 {2 N6 ~# _& ]) p6 y
  L& f' n% A0 _/ e) l11)
8 ?+ q2 e# {5 c( y& \! V7 K1 aEnter a Class name and uncheck all method stubs options
( x. M5 ]2 T; h* k+ Y
$ u+ H2 |! ]4 H% y+ l12)
; z: v9 M6 Y$ ]& X7 g) bNow 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./ j2 P" ?, q) P& z2 ?0 s
First we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java
- T- J( j$ Q: ~, h8 i1 E* f$ {( X0 z: X; q: h0 x
13)
6 T8 H) o$ B  e1 sStart Recording by Tools -> Journal -> Record
) }( \% P7 k0 P$ x8 ^4 a. i$ {  _$ ~2 K6 Z' H
14)
4 u7 C# R0 N# fCreate a Block and finish the journal by Tools -> Journal -> Stop Recording
" t1 w  M+ _; o9 P. l
; V' v6 h- N' q9 y' c6 U15)
# P6 T  I! w2 ~: Y* DOpen the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file# `$ p7 M$ l0 N

) ^" W7 v/ O4 g( c* L; ?/ }; v$ w& S16)
) [* l9 c' ~. [) d) vMake a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”( i$ r* N& e1 u

) o0 K8 a" [1 J+ F1 G17)2 {3 X9 C+ `  g8 g& F. q
Finally we create the Jar file which is mandatory in case our package contains more than one class.
6 u: M8 f9 o& oIn the Package Explorer right click on the project name and select Export -> JAR file -> Next) N. [. v+ J- N4 D& O
; ~9 f7 s! ?" d4 e! W+ N, P
18)# [9 T4 B0 B' O) X* R' c
Select the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.2 h" q3 K- M; {; q
( {9 Y& r$ s" o' `4 |( O! l
19)5 p- o: Y/ b9 z; [- P
Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish9 d& U6 }" Z/ d( O' ~
  H: t1 n" F' H' }+ w

- V1 F# O* p8 r6 g; r" a" pDebug the JAR or CLASS file with NX and Eclipse
7 U5 s/ j# a( X" {
1 [9 G9 V4 r( s2 @20)" W. |1 W% B' `  u
If 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 .
( f5 J5 a% T' O  t3 J* ODue 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.; {& l8 E. @( Z& S/ }. P
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.
3 d7 [8 q: t1 VFrom a NX8 command prompt, we enter the following commands:
9 ]' u/ a1 A) [" Y
+ T+ ?/ U/ ~; L% s0 k$ ^>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n+ v% Z2 p, }, T# T: \8 m9 v
>ugraf.exe. d" {/ d+ f& K" Z
* V6 b# k0 [9 ]# t( L
Then we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.
9 ]* ~. ~6 E0 HAny simple class will do the job, for example a famous HelloWorld class." `& P8 |* E" X* M
/ S. x3 |' U9 a0 w- h- `2 E, H& U
21)9 M3 \. W! ~& Q2 ^5 a$ y
Create the external access to the JVM session in Eclipse by Run -> Debug Configuration.7 f+ q& m: [+ Z9 Y0 |3 q
On the Remote Java Application node make a right click and select New 8 ]1 T5 d* b( d- D$ ~0 v
5 ]  ], i" t# ]- o' g+ }
22)
. ^0 C6 F0 S0 t% C7 k) b$ OEnter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS& c# l, Z1 \+ _+ `

, A0 R- l" B  l' q5 B23)" X1 i$ h& \/ L
Don’t forget to set one or more breakpoints in your code where you want to interrupt execution
" a  d# q7 }' b0 F0 [- d7 c7 u3 e0 c: f; E. R5 i
24)
& n' c1 D# ^9 F/ ], x  T) Y5 |Finally execute the JAR file or CLASS file in NX that you want to debug.( @/ P* A, t6 Y6 W/ {7 p
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.
, |: ]; K4 r  }/ |0 t; ]3 m' K* h! k# l  u' M
That's it.
( g/ ?+ Q& e; z# p8 d& v# c
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了