niedzviedz
Mechanical
- Apr 1, 2012
- 307
Hello,
I wanna write some journal to process whole assembly and display only parts with broken links. Below is code which I mix with two codes.
Unfortunately it doesn't work like I want, because it don't display broken links. Separately second code (the one to display broken links in part) works perfect.
I also would like to add feature to display parent, something like that:
But I gets error.
Any one can help me solve what I did wrong?
With best regards
Michael
I wanna write some journal to process whole assembly and display only parts with broken links. Below is code which I mix with two codes.
Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies
Module NXJournal
Public theSession As Session = Session.GetSession()
Public ufs As UFSession = UFSession.GetUFSession()
Public lw As ListingWindow = theSession.ListingWindow
Dim theUfSession As UFSession = UFSession.GetUFSession
Dim sourceTag As Tag
Dim linkBroken As Boolean = True
Dim workPart As Part = theSession.Parts.Work
Dim dispPart As Part = theSession.Parts.Display
Sub Main()
lw.Open
Try
Dim c As ComponentAssembly = dispPart.ComponentAssembly
if not IsNothing(c.RootComponent) then
ReportComponentChildren(c.RootComponent, 0)
else
lw.WriteLine("Part has no components")
end if
Catch e As Exception
theSession.ListingWindow.WriteLine("Failed: " & e.ToString)
End Try
lw.Close
End Sub
'**********************************************************
Sub reportComponentChildren( ByVal comp As Component, _
ByVal indent As Integer)
Dim dispPart As Part = theSession.Parts.Display
Dim Length as Integer
For Each child As Component In comp.GetChildren()
For Each theFeature As Features.Feature In dispPart.Features
If theFeature.FeatureType.Contains("LINKED") Then
theUfSession.Wave.IsLinkBroken(theFeature.Tag, linkBroken)
If linkBroken Then
lw.WriteLine("link to parent geometry is broken")
lw.WriteLine(" " & theFeature.GetFeatureName)
end if
End If
Next
reportComponentChildren(child, indent + 1)
Next
End Sub
'**********************************************************
Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function
'**********************************************************
End Module
I also would like to add feature to display parent, something like that:
Code:
lw.WriteLine(" " & theFeature.GetParents)
Any one can help me solve what I did wrong?
With best regards
Michael