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 4549 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 H& Y9 ^, d9 W1 P9 m& k. Y) @6 S7 A4 N" e7 o0 l% \+ A5 m
(see PDF in the ZIP file for a pictorial description)1 _# f% X8 m$ R/ e  q

6 }" K4 Y8 y6 h  jInstallation of Java and Eclipse+ j* g$ [( m0 r8 U4 Q, @

. t. `+ r- ?5 H) F9 P0 C. ?1)
3 I% _  r- k5 {Download and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from
* m2 a+ P4 \; Bhttp://www.oracle.com/technetwor ... ownloads/index.html
& F- \. O/ d) d7 e! v6 z  y0 [, {' ~/ J% g0 E+ |
2)
# ~, t: l/ U: o/ |Download the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads
' w# t6 Z7 F% o! E7 pand extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”
" u1 N9 Q3 k7 q) ~+ k: z- f0 z2 f/ g) D2 N* J7 X3 y- A) v

1 F, [- `- y5 O- b% q5 XCreate a project with Eclipse   1 F* |( m  H+ i3 E/ S. k! O
5 \- f/ r' c7 a, ?- }
3)/ g- }9 w. _; \* N( U6 T# x
Start the Eclipse IDE, for example “d:\eclipse\eclipse.exe”
& ]4 S- h9 `) S' J  o3 ^2 k; E/ S% q6 n5 H
4)
7 S3 Z% @1 y5 H( Y8 ^, r" ^) u" m' \You will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio, |4 g4 k+ c2 j. }4 ?

$ h$ S0 {  ]) H, s# d5)/ i$ Y4 @' x+ D1 W6 J' B1 L+ V1 T+ g
Create a new Java Project by File -> New -> Java Project
' ^5 ~4 E9 o8 g$ A1 a& a, f8 }2 g: w, A' K5 D& a& p. u
6)
" \; b; ~1 k5 {9 b5 JEnter a project name and continue with Next9 e; ?3 F( I, Q! P. K, f# \  ^

( x1 W2 n* Z2 \0 J. V& o- f7)
/ w2 z! N# Q( l; P# zOn the Libraries Tab add the external NXOpen Jar packages and Finish
0 {& K, f- z! E  l; M  f) r7 O" e% m+ N8 W4 R* l
8)
, \" n5 k9 b8 _6 y$ V4 [- R- {In the Package Explorer window make a right click on the project name and create a new Package (Namespace)  
6 \* K8 [+ t$ [' c- x1 |9 x
/ A: T: W! n8 j9)
  {! X8 ^- ^1 ^7 T* b% X" R) aEnter a package name and Finish# {9 o0 E) X) n: X1 ^2 D+ k  u! v" \

$ G. {4 E; K) [! i10)
$ b$ {* G! |# q! s2 JIn the Package Explorer window make a right click on the Package name and create a new Class    5 I( P5 w$ |; l% s: I2 t3 X! M; D' D
! A6 T# n0 q- Q- u( Q) [. s
11)3 W4 X  A+ I! Y. o- g3 j3 K. A3 i1 ^
Enter a Class name and uncheck all method stubs options
2 D; A8 t- G, \& v" R2 k9 ?
; t! ^8 ^; v& z' ~& t/ o12)* c9 Y; }2 |) {. A4 M: E
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.
4 L* a7 Q: `# v9 |First we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java/ F4 h0 s7 e* p

" E  B/ z. v2 L' b6 A" C8 j1 b13)
) E4 _+ [0 N/ RStart Recording by Tools -> Journal -> Record% d6 Q  a0 q3 a

& R" x8 q8 p3 S: G1 k6 q. ?14) : f8 f/ C7 t% k6 [7 V5 w7 ?4 U
Create a Block and finish the journal by Tools -> Journal -> Stop Recording3 d0 M4 j+ V- I, k: ~- a9 v

* D3 X) @: `+ F" k( ]0 v) F) \$ a1 q1 X15)
+ [* s/ `, D/ ^, cOpen the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file
& w- O0 w+ f8 Y  a. \) t) Y' v2 U* Y9 s2 G0 c' Z- ]
16)
3 o0 [- D" V0 ?. [; m/ L9 TMake a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”$ C2 m, O$ _+ A; N, B

7 F9 z' I. m$ @3 S17)
/ R- o+ e+ C8 L7 ~& y3 L' gFinally we create the Jar file which is mandatory in case our package contains more than one class.
! c% b  K4 N2 ~' I1 c1 _  o$ sIn the Package Explorer right click on the project name and select Export -> JAR file -> Next
5 _) X& l- i. S( [0 t& B( i* x# [( Z# `: q2 Y- s
18)
/ H% ]; h- Q' F. c' LSelect the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.9 |, n4 j+ y+ K  Q; @

: P$ b: i' t# w19)9 C5 r/ r1 ]& ?" C' j0 T5 U. y
Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish7 G* K" z9 p; I  J3 w+ d
. E! D0 P: a) [3 ~1 u0 `

* s8 _9 m! g# X# \8 h4 ADebug the JAR or CLASS file with NX and Eclipse
: I& f  v, R5 C4 e7 A% t$ V8 P3 W4 Q
% O. n. ]. a% \- @; F20)( ]7 ^3 u; I! u4 m. I/ S' C
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 .
: J9 V9 m8 s# t! t, y" t. VDue 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.* \4 v8 o0 V7 `' g, ]# l
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.
; W3 I2 t& B& _From a NX8 command prompt, we enter the following commands:  p$ h( j6 [: w% l0 y+ q

  r, O) X5 J, H4 a>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
" ?0 X5 n6 C; P. v( _>ugraf.exe
, b3 Y3 Q) y& I+ S* \5 E
6 |0 e- K! c) M6 ~Then we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.* d# f, S& z- Z; b  ~( O
Any simple class will do the job, for example a famous HelloWorld class.
2 o% W% a9 u% Z: @) Z' M% U
- X" X. L# f5 r' c& t21)1 q( Q* ?* P7 E1 J& z, Y
Create the external access to the JVM session in Eclipse by Run -> Debug Configuration.
4 m8 k2 A. L$ \8 e0 ]; @On the Remote Java Application node make a right click and select New
* m0 n3 U( C6 b3 b# i; g1 u
; W& y) K5 Q: i. i5 t" H$ c22)
0 r5 H* m% v7 i/ N( `7 c, }Enter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS+ i9 j: m2 v  W, V4 Z% z6 |
: m" p8 v' P, m- F" G2 U7 ~
23)5 Q7 ?" V3 w+ U- O7 C0 ^7 p/ a% U- {
Don’t forget to set one or more breakpoints in your code where you want to interrupt execution
/ o9 N% t3 R2 z) Z+ ?- \' Z; S
24)
; r+ Z) q" y/ i. [Finally execute the JAR file or CLASS file in NX that you want to debug.
# u* i( t, U/ w$ m4 b/ x3 bOnce the breakpoint is hit, switch to the Eclipse application, confirm to change to the Debug Perspective View and Step through your code as desired.
; O3 l$ S1 z( g* u! H  a- Q( i+ |! A: ?7 l
That's it.! \+ ~0 f( b% N: c: z4 h- v
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了