Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

NX 10 - Bug in PartCollection?

Hello everyone,

 

I'm trying to implement a watcher which gather all parts loaded in NX 10 (exact Version 10.0.1.4 ) - not only the parts shown in a single window


To get all these parts I've thought it's best way to do this is to use the PartCollection.

JAVA CODE 

1. Session session = null; 2. ArrayList<Part> parts = new ArrayList<>(); 3. try 4. { 5. session = (Session)SessionFactory.get("Session"); 6. PartCollection collection = session.parts(); 7. 8. for(Iterator it = collection.iterator(); it.hasNext();) 9. { 10. Part part = (Part) it.next(); 11. parts.add(part); 12. } 13. }
14. 15. catch (Exception e) 16. { 17. // exception handling 18. }


The Problem is that the programm crashes at line 8 with the following exception:

 

java.lang.RuntimeException: nxopen.NXException: Object no longer exists

I searched on the web and some people are saying that this might be a bug!?
Even if it is a bug or not is there a solution for this problem or any other way I can do this?

 


Many thanks in advance

5 REPLIES

Re: NX 10 - Bug in PartCollection?

You say you're creating a 'watcher', not sure what you mean by that. Anyway we are iterating over the PartCollection in just the same way using Java without problems in our code.

 

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5

Re: NX 10 - Bug in PartCollection?

I don't know Java, or how the NX iterators work, but judging from C++ STL iterators, I'd check a couple things:

 

1) is "Part part = " a deep or shallow copy?  (i..e does "part' contain a copy of the data from it.next?  or just pointer to the data pointed to by it.next()?)

 

2) I'd print to the info window the "part"s name - to see which parts are being found.

 

3) does "part" get assigned before or after when the .next() is applied?

 

Normally, STL iterators are initialized to .begin() (i..e the first element in the collection).  So I'm a bit puzzled why the it.next() is within the loop, not at the end of the loop (or after the 2nd ";" in the "for" statement)

 

Again, this could be how Java/NX iterators work, I don't know.

 

Ken

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: NX 10 - Bug in PartCollection?

[ Edited ]

@Inch
Thanks for your reply.

In this case the watcher represents a list of parts opened in NX. This list will be send to an external programm such as TeamCenter. The watcher runs in a thread which will be called every 10 seconds.
But thats not the point.

 

You say you'r running the same code in Java?
Which NX version do you use?


@Ken_A
In Java there is no begin for an iterator. The code itself should be correct but I don't know where the exception comes from.

1-3) Lines 10 and 11 wont be executed - so I dont know which parts were found. The part itself should be a copy of the it.next()

But as I mentioned above is that the programm crashes at line 8 with the following exception:

 

java.lang.RuntimeException: nxopen.NXException: Object no longer exists



EDIT:
I tried NX 9 and it works perfect. Obviously there must be a bug in NX 10!

Re: NX 10 - Bug in PartCollection?

We're still in version NX8.5.3.3 MP4
Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5
Solution
Solution
Accepted by topic author jedwinpdm
‎08-28-2015 06:38 AM

Re: NX 10 - Bug in PartCollection?

There was a prpblem with the PartCollection in NX 10.

 

Theres a Fix in MP1 for the 10.0.1 releases.

Or you directly upgrade to 10.0.2. I had the same problem in 10.0.1.4. with Python. It is definitely fixed in 10.0.2.

 

Best regards

Boris