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

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

[复制链接]

2015-2-25 13:02:01 4763 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 3 r7 b8 G( K3 r1 m
6 I! l! Y( V4 g- M" Q+ G
(see PDF in the ZIP file for a pictorial description)& {0 L& r0 H3 C7 x

2 G4 n: j8 g  y& sInstallation of Java and Eclipse: Z5 c- ~0 b- O4 [. t7 u  m' K4 h
/ S' R# Y/ r9 v# i
1)
. c: |, g. X3 w9 u; e2 ~% R% pDownload and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from7 t6 _8 X0 l/ b  {* e/ n6 Z0 H
http://www.oracle.com/technetwor ... ownloads/index.html ' f6 }* Q' p' V7 W3 d
' L& i% ^. i! W" v+ t
2)
" z7 }" ]) k2 rDownload the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads 4 z" u+ E$ j2 C4 q4 r
and extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”8 ?9 p% [' |# T
+ X0 q% c# D& g2 N/ N# [

6 Z: m  a* x8 J1 kCreate a project with Eclipse   
- S+ J6 A+ q$ T0 J  W
: g$ e" m2 m6 w% K) s3)
# Y* e7 r) g) Q& ~6 \4 w" sStart the Eclipse IDE, for example “d:\eclipse\eclipse.exe”
, p5 Q( \' o" n( U' ]
/ T  q8 {! R7 v; I4)% I% Z. C1 ]7 V9 n% X, o6 Y/ ?
You will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio- V- p) K% x4 ?9 m5 `$ z
$ D; ]$ Q4 A& w- f- A3 r) k9 K5 R
5)% i; m- S; h+ f" G' h
Create a new Java Project by File -> New -> Java Project, N8 k. m$ l& M* Y6 c1 ]

+ s7 A' k0 H9 s4 U0 c* l6)8 k1 p. @; b4 S0 f' x- K* B# K
Enter a project name and continue with Next
6 w" [% E; a. z% T9 P5 d" H& d+ q. y$ `' M6 I  C
7) 3 R4 ^) s% j( x6 A) ~
On the Libraries Tab add the external NXOpen Jar packages and Finish
) N8 E2 g9 w4 t1 X* ]4 A
! k8 s* w% c. r8): L$ M9 q: k1 t# s; z* i
In the Package Explorer window make a right click on the project name and create a new Package (Namespace)  0 ]! a5 X; @8 \9 ^# v3 m- W: z

3 d( G: k7 M) _+ i# ^9) " n4 ~( A" s1 n% |" Z- s
Enter a package name and Finish
" {% I. Q& |/ ?- ]3 h7 ]! f3 [# c1 F1 E4 b; M9 ^
10)
2 b3 X# H; j2 e5 w3 |0 o5 x! z- tIn the Package Explorer window make a right click on the Package name and create a new Class   
$ K" h! F5 z' F
  W8 }" C4 {! y6 s' t; ]; }3 a11)
" m" i* w2 t5 Y2 e5 AEnter a Class name and uncheck all method stubs options1 B$ x9 u! q/ P1 ]( {

- g2 B* k, n( x' K! _: V- Y* G12)0 T$ h- b1 u1 n' h5 C1 E4 g( b; }" p& R* l
Now 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.
6 _8 c) u+ J; O1 p9 K% C6 UFirst we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java0 Y2 D2 M* n, e- q% F
! ~  K7 I) @) l
13)$ l' K' D1 I2 H7 A. b/ e4 H0 _
Start Recording by Tools -> Journal -> Record
+ _) w" p. e6 Z% Y7 S
6 S& h) l0 ]6 \& X- S7 H14)
: E8 k, }: O% G. _Create a Block and finish the journal by Tools -> Journal -> Stop Recording
3 m! V* P: W8 ~& b9 V- J/ G) Y& F1 S* ]  B
15)
8 }9 m4 d& u7 S" t4 LOpen the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file/ N( U8 h  @% R# F

3 a, X' }' h! y  h  Y16)
! V3 _# Y7 L% o4 ~Make a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”
. w+ s  {# U5 p. w1 w; W! n
! `9 e# k! e% m+ j17)& Z; O! T7 I; `, g; m; x& G
Finally we create the Jar file which is mandatory in case our package contains more than one class.; R9 k& ?1 y! d0 |/ p
In the Package Explorer right click on the project name and select Export -> JAR file -> Next' x/ N* s' L% m- J, f
4 t# k/ N0 w4 C% l" x
18)
9 l0 |8 A4 O0 @3 \. v# P* SSelect the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.9 x2 d. l# H. m
& ]6 P( d" k. p2 j; W5 c; c
19)
7 x% ]' ?3 R8 j" i, jThen proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish
8 I2 {! Y% }# f% l1 e! X/ {
. W4 j( h7 w2 z" c1 t2 O) l
! N$ [7 Z: |  X& ?) g& _+ C$ x$ {4 _! GDebug the JAR or CLASS file with NX and Eclipse
% q: b6 T( n+ A% U4 M' C( O$ }5 m0 r  s  Y& X( u' L
20)
+ @- |  Z% ^: N5 d& Y9 [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 .9 t' ^/ X# i6 Z, Z6 f  e/ D
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.
( g% _& z4 w" U2 ?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.' f+ ^# O. B/ d
From a NX8 command prompt, we enter the following commands:
% e; C3 p1 P& b
3 Y, C* q5 c# u0 _4 [>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
9 {. e1 H- t3 c  J; t' u>ugraf.exe
. J. p2 l. T/ H4 K) b* V! y# `
; |1 I( ~$ ?/ G2 y1 o3 oThen we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.
+ [* b' B: \/ ]% Y5 d9 tAny simple class will do the job, for example a famous HelloWorld class.3 f6 q8 b) u8 }* Y, u$ ~  _3 e) X

* p2 {/ o8 d; K1 D% F9 b. c' M21)
7 F1 l! I0 F* ~Create the external access to the JVM session in Eclipse by Run -> Debug Configuration.& j3 @+ O$ x( t* ?
On the Remote Java Application node make a right click and select New / w2 S# k3 k5 m: X& t

/ n* ^  F! u8 n8 N1 y1 y) |$ K* _* q22)
7 O+ j& ?  I3 g2 uEnter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS
  Q/ s$ n0 J, f1 U+ A2 ]2 U* M: l2 n: L% x" k8 V) K
23)
, ^* N" ]" ]' s' Y; fDon’t forget to set one or more breakpoints in your code where you want to interrupt execution5 U; h5 l1 v) a' H, v

' G9 T! I% @9 x; P/ z- u8 i+ f24)
, k4 m2 Z0 b7 T# v2 |Finally execute the JAR file or CLASS file in NX that you want to debug.6 t& s6 w1 a! e& l5 q. U6 V2 M, O
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.
2 \. m. ~; t+ d1 L3 [( l, q
0 I( U, A+ u( p+ `That's it.
3 Q9 p; S. U- e7 i. B# C
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了