New to SNAP, Trying to open all the parts in an assembly;
For Each child As NX.Component In children
InfoWindow.WriteLine(child.Name.ToString)
InfoWindow.WriteLine(child.Name.ToString & " : Leaf : " & child.IsLeaf.ToString)
InfoWindow.WriteLine(child.Name.ToString & " : Hidden : " & child.IsHidden.ToString)
InfoWindow.WriteLine(child.Name.ToString & " : NXOpenTag : " & child.NXOpenTag.ToString)
InfoWindow.WriteLine(child.Name.ToString & " : FullPath : " & child.Prototype.FullPath.ToString)
InfoWindow.WriteLine(child.Name.ToString & " : Prototype.NXOpenTag : " & _ child.Prototype.NXOpenTag.ToString)
next
I get results for everything except for prototype. Which crashes the program when a part is not loaded.
The error message : "Input tag is NXOpen.Tag.Null"
I need to know how to make sure all the parts in the assembly is loaded and how to avoid crashing the program if a part was not loaded. I tried by getting the NXOpen.Tag value. but refering to the prototype causes same problem.
Anyone knows how to get this information with having the user opening the assembly first?
Thanks in advance
Stan
re: is component loaded?
Below is the overall code structure that I use to determine if a component is loaded or not.
Private Function LoadComponent(ByVal theComponent As Component) As Boolean
Dim thePart As Part = theComponent.Prototype.OwningPart
Try
If thePart.IsFullyLoaded Then
'component is fully loaded
Else
'component is partially loaded
End If
Catch ex As NullReferenceException
'component is not loaded
End Try
.
.
.
Owning part is not a member
Hi,
Thanks for the lead;
intellisense tells me that "Owning part is not a member of Snap.NX.PART"
I found this "Dim thePart As Part = theComponent.OwningComponent" but it said it cant convert this to NX.Snap.Part
Where am I going wrong this time?
Thanks in advance
StanV
re: Snap.Nx.Part
I should have mentioned that the code above isn't using a reference to the SNAP library. If you are using SNAP, you should fully qualify your variable declarations to avoid "namespace clashes". Instead of
Dim thePart as Part...
use the following:
Dim thePart as NXOpen.Part...
Use the fully qualified name of any variable type that is used in both the NXOpen and SNAP libraries.