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 4547 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 4 D% ^0 q, t* j; }- Z+ x" R

; G! ?, A3 D5 x% O9 P3 I9 k9 [(see PDF in the ZIP file for a pictorial description)6 N8 G" G" [+ v! E4 R, _
1 t, _( `0 M' W3 U: }* J
Installation of Java and Eclipse
+ B4 j8 d2 O! p& E% r" O3 U/ g; X! n1 G2 u. W
1)! H$ z6 p' \6 b+ a6 T9 `, p) J/ I: A
Download and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from$ I; F1 e' \: \- H) b2 g/ s
http://www.oracle.com/technetwor ... ownloads/index.html
* i  S6 X1 `2 F# E: v# Q1 J. Z2 m$ ?2 G$ c- ?9 g, a' K" ^
2)
6 x8 W$ H; T7 E; A0 ?Download the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads - Z6 N% H7 F3 e. t
and extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”
$ Q& }) F* v: |* Z) Q3 Q( v/ z$ g4 |9 p0 N6 A
. c' i- R1 ~' T7 Z$ Y) s4 t3 u
Create a project with Eclipse   4 q* w; p, i0 n7 \; `$ X. o
9 v+ F3 W5 P) X6 C" a6 @
3)
: Y4 H, Q5 h7 w" O# x7 @Start the Eclipse IDE, for example “d:\eclipse\eclipse.exe”& z' C& ]4 j6 J) q+ u" Z
3 d. @: D. ]# x9 L  o2 g# i7 o( e
4)1 Z1 q7 M/ `0 F3 O7 {& p, [1 J
You will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio. t* G+ v% \8 ^4 @0 {

, y( V  J# s+ J4 ]/ J" `: G5)
0 ~. M6 ~4 F7 y  B2 \Create a new Java Project by File -> New -> Java Project/ X( I& _( G5 D& k  {- E  H
( ^8 F& a* W, A& z) Q6 O9 x7 B- i
6)
2 D4 ]/ s1 M  z) j$ `! p. HEnter a project name and continue with Next1 L$ n; w8 A0 `  \1 o; w

% g$ M% S4 T6 t7 b9 @3 e7) ( L9 {& |1 q; m/ p" ~# T
On the Libraries Tab add the external NXOpen Jar packages and Finish9 K( q  G. E& h: j! `+ u
# R9 M0 Z/ ]" y2 s0 u' l& d
8)' J+ e  v# n  a/ K2 ?" e6 z! E
In the Package Explorer window make a right click on the project name and create a new Package (Namespace)  & m, S5 d" \! i- C# d. S" U

$ t6 h  y) K1 ]- o9) & B; w1 ^9 k( a' J
Enter a package name and Finish1 A: a3 o/ d. z" \8 z7 M
+ _8 D$ J+ {( @9 K
10)
4 a" w/ Z, S4 \5 EIn the Package Explorer window make a right click on the Package name and create a new Class   
2 e$ G3 R. [" D: B1 y* S  S
7 c) L' i5 v8 ]3 L11)7 U# u- x- k5 F4 }7 M
Enter a Class name and uncheck all method stubs options
+ t& B9 b8 P5 R, _4 f% i* ~3 S
1 c* V9 l+ ?! \8 H; K2 ~12): Q( t3 z9 c; ]+ C& P: |
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.' V* c. M' k- e$ N
First we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java; [, X! r! W8 b  w: m% t" j
8 q5 M+ c5 a* X8 Z8 ^
13)
, F9 Z7 z1 _; G% T; l0 ?: g0 hStart Recording by Tools -> Journal -> Record
! w! `4 A* b1 ^
5 l1 Y! D3 V+ [7 e7 s9 @, D14) 1 R* B) l. l' C8 b5 M
Create a Block and finish the journal by Tools -> Journal -> Stop Recording  a$ `6 P7 H4 m2 N4 R) v% N

0 q; ~, `+ S0 F15)
( C1 H. D+ }! B6 l$ TOpen the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file
7 J8 }" T. E* I, v
: h; o. F/ I, P1 `16)0 D; B0 H3 I7 r4 V' I0 v9 p
Make a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”
8 e& [6 X" |+ b/ w3 Z. p# \5 D; |. t
9 B" L$ `3 w) f. Z& B17), O: J1 @; ~+ d7 k7 h; W( R
Finally we create the Jar file which is mandatory in case our package contains more than one class.
1 f- K1 t% b3 ~7 j  _. LIn the Package Explorer right click on the project name and select Export -> JAR file -> Next# ]& j" K2 G5 P$ i2 S
' u2 h. R2 ?* u: W9 e2 B2 D
18)
  v/ u2 h6 }% j3 k7 n  q* BSelect the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.
4 ~& P( r7 g; B7 p# S. Y' O; T# w) r/ h
19)
8 {( w$ ~6 ~; S6 R8 T5 q% jThen proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish
0 ~, R8 O; ]% W1 |% p4 l. {* j# m. [+ Z0 C

' p! u1 ?( K3 C# ADebug the JAR or CLASS file with NX and Eclipse
* |2 u( G/ H1 _! C1 s8 S+ ~' f- h3 k0 O- \3 g! J$ D4 ~* ^- e
20)
/ v3 B8 G. X5 F" Q% n  F$ uIf 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 .
2 x# f$ B: v- W7 X5 M4 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.
; ^2 Y0 y5 |6 p( u& f5 a  KIn 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.% I) L2 G. c% P. v! x
From a NX8 command prompt, we enter the following commands:; }0 C; z' y8 X" D: w7 n7 X, Z. y' g
8 h7 n/ X8 y  z! [  t8 S" q
>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n7 p1 W3 v  P5 P) K5 \
>ugraf.exe
- Z% q5 E) \1 L) W9 q6 r) S9 a5 e- g2 `; ]! B- R! @* s: z' c
Then we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.! z% N: Y. x: w1 T  i1 h& X
Any simple class will do the job, for example a famous HelloWorld class.
" f. S3 v3 @$ a2 g2 A7 n" u( a2 n9 Y
21)5 f( W+ H2 ]+ w+ n, w7 ?' K
Create the external access to the JVM session in Eclipse by Run -> Debug Configuration.  R% u6 e9 s: u) x  u# k
On the Remote Java Application node make a right click and select New
. M4 J1 |! }4 d& S0 q8 z5 S- q7 k; q2 z+ m1 v) X) W: B2 g
22)
7 o, K$ T) ]: v! W  _; X6 Q$ rEnter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS. S, P: q3 D* h  `/ e: m( S0 T
! v- T/ S+ e. K9 t' L4 i
23)
1 V3 r$ o$ b% M; {  kDon’t forget to set one or more breakpoints in your code where you want to interrupt execution9 M/ E( R7 t1 z' S( _8 Q# u
% z, N2 l1 _. k5 ]: ^
24)6 f  N: D  V$ j. e  a
Finally execute the JAR file or CLASS file in NX that you want to debug.
: |) T, A/ ?5 q8 R" h" o+ j9 E5 s/ y3 e  \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.
  Z! g* |+ h' C% d6 `1 H4 j3 D6 O6 r' r* d% {$ g# j1 ?
That's it.+ V2 R3 W) r0 Q) S4 P
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了