×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Broken Links

Broken Links

Broken Links

(OP)
so i have bits of code that i found somewhere on web (if anyone knows the code please post the source)

The Journal its suposed to look for broken links and report the assembly that contains the bronken link aswell as the parent feature and to who assembly links belong.

somehow its not working in some links (image attached)

its not a broken link ?


CODE:

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.WriteLine("FIM")
    lw.Close
 
    End Sub
 
'**********************************************************
    Sub reportComponentChildren( ByVal comp As Component, _
        ByVal indent As Integer)
	
        For Each child As Component In comp.GetChildren()

	    If LoadComponent(child) Then

'		lw.WriteLine("file name: " & child.name)
'		lw.WriteLine("  ")

	Dim MyPart As Part = child.Prototype.OwningPart
	Dim sourceTag As string
	Dim Partname as string

	   For Each theFeature as Features.Feature In MyPart.Features
            If theFeature.FeatureType.Contains("LINKED") Then
               theUfSession.Wave.IsLinkBroken(theFeature.Tag, linkBroken)
			
                If linkBroken Then
			theUfSession.Wave.AskbrokenLinkSourcepart(theFeature.Tag, Partname, sourceTag)

		lw.WriteLine("file name: " & child.name)
		lw.WriteLine("  " & theFeature.GetFeatureName)
		lw.WriteLine("		parent file: " & Partname)
		lw.WriteLine("  ")

		end if
           End If		
        Next
               Else
                'component could not be loaded
            End If 		
            reportComponentChildren(child, indent + 1)
        Next
    End Sub

    Private Function LoadComponent(ByVal theComponent As Component) As Boolean
 
        Dim thePart As Part = theComponent.Prototype.OwningPart
 
        Dim partName As String = ""
        Dim refsetName As String = ""
        Dim instanceName As String = ""
        Dim origin(2) As Double
        Dim csysMatrix(8) As Double
        Dim transform(3, 3) As Double
 
        Try
            If thePart.IsFullyLoaded Then
                'component is fully loaded
            Else
                'component is partially loaded 
				lw.WriteLine("Componentes nao carregado completamente: " & Partname)
            End If
            Return True
        Catch ex As NullReferenceException
            'component is not loaded
            Try
                ufs.Assem.AskComponentData(theComponent.Tag, partName, refsetName, instanceName, origin, csysMatrix, transform)
 
                Dim theLoadStatus As PartLoadStatus
                theSession.Parts.Open(partName, theLoadStatus)
 
                If theLoadStatus.NumberUnloadedParts > 0 Then
 
                    Dim allReadOnly As Boolean = True
                    For i As Integer = 0 To theLoadStatus.NumberUnloadedParts - 1
                        If theLoadStatus.GetStatus(i) = 641058 Then
                            'read-only warning, file loaded ok
                        Else
                            '641044: file not found
                            lw.WriteLine("file not found")
                            allReadOnly = False
                        End If
                    Next
                    If allReadOnly Then
                        Return True
                    Else
                        'warnings other than read-only...
                        Return False
                    End If
                Else
                    Return True
                End If
 
            Catch ex2 As NXException
                lw.WriteLine("error: " & ex2.Message)
                Return False
            End Try
        Catch ex As NXException
            'unexpected error
            lw.WriteLine("error: " & ex.Message)
            Return False
        End Try
    End Function

'**********************************************************
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        Return Session.LibraryUnloadOption.Immediately
    End Function
'**********************************************************

End Module 



NX8.5 - NX9 User

RE: Broken Links

The link that you show technically isn't broken; a broken link would show a broken chain icon (see below).


Perhaps your link specifies more than one body, but one of the bodies is missing. If the other body(ies) update, then the link is not considered broken, but it is missing a reference.

The code that you posted looks like it is *mostly* mine from an early version of finding wave links in parts. The latest (published) version can be found here: http://nxjournaling.com/comment/2354#comment-2354

www.nxjournaling.com

RE: Broken Links

(OP)
yes i think i remember talking to you about it

Thanks i will do some tests and post feedback


NX8.5 - NX9 User

RE: Broken Links

(OP)
well the code that ive posted its working a bit diferent, it processes all components (if fully loaded) and report the broken link (the part of the bronken link) and the link itself (or suposed)


broken link 1
Filename (where is broken link)
Feature(number)
Parent File (of link)

broken link 2
Filename (where is broken link)
Feature(number)
Parent File (of link)


NX8.5 - NX9 User

RE: Broken Links

The code that I linked to only works on the current part. There is another version that does the entire assembly, but I'm not sure if it is posted on the site. If you combine your code and the code I linked to, you can get a version that analyzes all the parts in an assembly...

www.nxjournaling.com

RE: Broken Links

(OP)
ok i will try combine and post the result, thanks.


NX8.5 - NX9 User

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources