cancel
Showing results for 
Search instead for 
Did you mean: 

Issue obtaining geometry (bodies) from components w.r.t. loading

Valued Contributor
Valued Contributor

In my application I collect all the components of a certain type, these componets are found all throughout the assembly, using their string display names. I then get the single body found on the specific reference set from each of these components for interrogation. However, in certain situations, the findOccurrence call returns nothing. I believe this error is related to how/if the components have been loaded.

 

Here is the psuedo code:

 

' Get desired components within assembly to interrogate
'
' Load desired components
'         Loads components in the correct parent-child relationship
'         so that the top level components load first, then the children, etc.
'         Uses theSession.parts.open(String, PartLoadStatus) method
'
' Change reference set of all components to desired reference set
' 
' Check to see if each component's part is fully loaded, (always returns true!)
'
' Get the body from the component you desired (sometimes returns nothing!)

 

 

The assembly structure is similar to:

 

Parent Component

         -  Child 1

                      - Grand Child 1

                                 - Even more levels

                                              - My components!

                      - Grand Child 2

                                  - Even more levels

                                              - My components!

 

During the program run the Parent component is the display and work part. Now, the reason I'm posting is due to the following behavior:

 

If I run the program on a completely dry session, no problems occur. All the components are loaded fully and return bodies.

 

If I run the program on a session that already has a few of the desired components loaded, errors occur. All of the components are loaded fully, however only SOME return bodies. I have not been able to, though from no lack of trying, establish a relationship between which components/parts I've loaded and which fail.

 

If I run the program on a session that has all the components loaded fully, no errors occur.

 

Does anyone have a clue? Do I need to include more information for assistance? Thanks,

 

jgolen

 

NX 9.0

NX 9.0.3.4 MP13
VB.net
Visual Studio 2015
6 REPLIES

Re: Issue obtaining geometry (bodies) from components w.r.t. loading

Valued Contributor
Valued Contributor

Hi, 

What is the exact error you getting when you run in the session with some component loaded?

Attach the source code, it would be easy to identify the problem.

Selvaraj C
CAD Automation Engineer
NX 9 | NX 11 | Teamcenter 10

Re: Issue obtaining geometry (bodies) from components w.r.t. loading

Valued Contributor
Valued Contributor

The "error" is not actually throwing an exception. The "error" I'm referring to is not being able to find the occurrence body. When I attempt to obtain the body using component.FindOccurrence(partBody), the method call returns nothing. 

 

As I stated previously, when all components are unloaded, the program succesfully loads all components and finds all bodies.

 

When some components are unloaded, some are loaded, the program successfully loads all components, but is unable to find bodies. For some reason these bodies aren't existing within the session.

 

When all components are loaded, the program executs successfully.

NX 9.0.3.4 MP13
VB.net
Visual Studio 2015

Re: Issue obtaining geometry (bodies) from components w.r.t. loading

Valued Contributor
Valued Contributor

Hi,

Check the component prototype object and body owning part object is equal or not.

This check will confirm the body and component are from the same part. 

 

Dim protoPart As BasePart = CType(component.Prototype, BasePart)
Dim bodyPart As BasePart = partBody.OwningPart

' Boolean must be true. That means body is collected from component part
Dim mustTrue As Boolean = bodyPart.Equals(protoPart)

 

Selvaraj C
CAD Automation Engineer
NX 9 | NX 11 | Teamcenter 10

Re: Issue obtaining geometry (bodies) from components w.r.t. loading

Valued Contributor
Valued Contributor

Thanks for the assistance,

 

If nothing is loaded, the body part's FullPath property displays the .prt file of the root component. The protoPart displays the .prt file path of the component's .prt. Thus the mustTrue boolean is always returned as false.

 

If some of the components are loaded, the components which are loaded follow the same behavior as listed above. The components that are not loaded do not return a body, therefore bodyPart is nothing, and the check cannot be computed.

 

 

NX 9.0.3.4 MP13
VB.net
Visual Studio 2015

Re: Issue obtaining geometry (bodies) from components w.r.t. loading

Valued Contributor
Valued Contributor

body.Prototype.OwningPart returns the same part file as the component.Prototype

NX 9.0.3.4 MP13
VB.net
Visual Studio 2015

Re: Issue obtaining geometry (bodies) from components w.r.t. loading

Valued Contributor
Valued Contributor

History tends to repeat itself... Opening these files up as parts does not guarentee access to the components occurence geometry. Opening these components up using the OpenComponents call on the other hand, does.

 

https://community.plm.automation.siemens.com/t5/NX-Programming-Customization/Mimic-the-functionality...

NX 9.0.3.4 MP13
VB.net
Visual Studio 2015