Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations Ron247 on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

This journal give correct output in NATIVE but Incorrect output in NX Manager (TC)

Status
Not open for further replies.

Ehaviv

Computer
Jul 2, 2003
1,012

Hi All

This journal give correct output in NATIVE but Incorrect output in NX Manager (TC)
can anyone explain why

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies

Module scan_assembly_toplevel_components_and_report_loadstatus

Dim s As Session = Session.GetSession
Dim ufs As UFSession = UFSession.GetUFSession
Dim dispPart As Part = s.Parts.Work
Dim lw As ListingWindow = s.ListingWindow

Sub Main()

Dim selectedComps(-1) As Assemblies.Component
Dim fmComps(-1) As Assemblies.Component
Dim n_comps As Integer = 0
Dim n1,n2 As Integer
Dim thisName As String
Dim rd_cnt As Integer
Dim counter As Integer = -1

Dim root As Component = dispPart.ComponentAssembly.RootComponent
Dim toplvlComps As Component() = root.GetChildren()

ufs.Ui.ExitListingWindow() ' Clear and close the window
lw.Open()
lw.WriteLine("")
lw.WriteLine("============================================================")
lw.WriteLine(" Program ... START ...")
lw.WriteLine("============================================================")
lw.WriteLine("")
lw.CloseWindow()

n_comps = toplvlComps.Length
lw.WriteLine("Top level components number = " & n_comps.ToString)
lw.WriteLine("")
lw.CloseWindow()

counter = -1
If (n_comps) > 0 Then
For Each thisComp As Component In toplvlComps
If ufs.Part.IsLoaded(thisComp.DisplayName) = 0 Then
lw.WriteLine("nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn")
lw.WriteLine(thisComp.DisplayName & " ==> Not loaded")
counter += 1
ReDim Preserve fmComps(counter)
fmComps(counter) = thisComp
End If
If ufs.Part.IsLoaded(thisComp.DisplayName) = 1 Then
lw.WriteLine("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
lw.WriteLine(thisComp.DisplayName & " ==> Fully loaded")
End If
If ufs.Part.IsLoaded(thisComp.DisplayName) = 2 Then
lw.WriteLine("pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp")
lw.WriteLine(thisComp.DisplayName & " ==> Partially loaded")
End If
Next
Else
Exit Sub
End If

lw.WriteLine("")
lw.WriteLine("============================================================")
lw.WriteLine("Number of not loaded components = " & (counter+1).ToString)
lw.WriteLine("============================================================")
lw.WriteLine("")
lw.CloseWindow()

For n1=0 To counter
If fmComps(n1) Is Nothing Then Continue For
thisName = fmComps(n1).DisplayName
rd_cnt = -1

For n2=n1 To counter
If fmComps(n2) Is Nothing Then Continue For
If fmComps(n2).DisplayName = thisName Then
rd_cnt += 1
ReDim Preserve selectedComps(rd_cnt)
selectedComps(rd_cnt) = fmComps(n2)
fmComps(n2) = Nothing
End If
Next
lw.WriteLine("x" & (rd_cnt+1).ToString & " " & thisName & " ==> Not loaded")

lw.WriteLine("------------------------------------------------------------")
lw.CloseWindow()
Next

MsgBox("Replace Components" & vbCrLf & " DONE" _
& vbCrLf & "Elbaz Haviv Feb 2016" _
& vbCrLf & "See Information Window")

lw.WriteLine("")
lw.WriteLine("============================================================")
lw.WriteLine(" Program ... END ...")
lw.WriteLine("============================================================")
lw.WriteLine("")
lw.CloseWindow()

End Sub

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

End Module

Thanks in advanced



































 
Replies continue below

Recommended for you

Hi All

More info

I run the journal in the same platform one time in NATIVE mode
and one time in NX Manager (TC)

and also the same assembly

THANKS
 
I have a theroy, but I don't currently have TC installed to test it.

I think the difference between native and TC lies in this line of code:
Code:
If ufs.Part.IsLoaded(thisComp.DisplayName)

According to the help file, {comp}.DisplayName will "Return the displayable name of the prototype part". In native NX, the displayable name will be the same as the part name; in TC it probably is not. When a part is imported to TC it gets a "unique identifier" assigned to it that is used as the part name in the database; you also get to assign a name to the part, such as 12345/A, but this is only an alias for the sake of "human convenience". If, in TC, the .DisplayName refers to the name that you assigned to it rather than the actual part name, it may be that NX can't find that part in session because the names don't match.

Try running the following code on the same assembly in both native and TC. If you get the same results with both runs, then my theory is invalid and we should move on...

Code:
Option Strict Off
Imports System
Imports NXOpen

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        If IsNothing(theSession.Parts.BaseWork) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Dim root As Assemblies.Component = theSession.Parts.Display.ComponentAssembly.RootComponent
        Dim toplvlComps As Assemblies.Component() = root.GetChildren()

        For Each tempComp As Assemblies.Component In toplvlComps
            lw.WriteLine("Display name: " & tempComp.DisplayName)
            lw.WriteLine("Part Leaf name: " & tempComp.Prototype.OwningPart.Leaf)
            lw.WriteLine("")
        Next

        lw.Close()

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module

www.nxjournaling.com
 
Hi cowski

I'm very thank you

Next sunday I'l be in work and I'l test your code.

note that the help for ufs.Part.IsLoaded say these returns
0 = not loaded
1 = fully loaded
2 = Partially loaded
and any other = error
logicaly if TC have invalid part name will throw an error ?

and note also that TC output is not loaded for all components

Thank you again

 
How would it know it is an invalid part name?

Does NX search through all the parts in every folder on your computer/network to determine the file doesn't really exist?
I doubt it.

More likely, it can't find the part in session, so it returns "not loaded".

www.nxjournaling.com
 

More likely, it can't find the part in session, so it returns "not loaded".

It sounds strong !!!

THANKS
 
Hi

Running the journal in the same platform on the same assembly
one time in tc and one time in native.

Give the same exception as follows:

NullReference exception on this line
lw.WriteLine("Part Leaf name: " & tempComp.Prototype.OwningPart.Leaf)

And until this exception the output is as follows:
In Native is

Display name: xxxxxxx-yyy_-
Part Leaf name: xxxxxxx-yyy_-

Display name: 1-1469492-3_B
Part Leaf name: 1-1469492-3_B

Display name: 1-1469492-1_B
Part Leaf name: 1-1469492-1_B

Display name: MS24693C3_abc

In TC is

Display name: xxxxxxx-yyy/-
Part Leaf name: xxxxxxx-yyy/-

Display name: 1-1469492-3/B
Part Leaf name: 1-1469492-3/B

Display name: 1-1469492-1/B
Part Leaf name: 1-1469492-1/B

Display name: MS24693C3/abc

Note that MS24693C3_abc is a hardware family member component.

Thanks in advanced
 
I had some time to revisit this. Try using the .Name instead of the .DisplayName.
Code:
ufs.Part.IsLoaded(thisComp.[highlight #FCE94F][s]Display[/s][/highlight]Name)
ufs.Part.IsLoaded(thisComp.Name)

www.nxjournaling.com
 

Hi

For native the output is the same as previuos post

and for TC is the same except for this line

previuos output ==> Display name: MS24693C3/abc

new output ==> Display name: MS24693C3

Thank you for this try
 
My apologies, I should have been more clear. I meant for you to make the change in the original code that you posted, not in the journal that I posted. After you make this change, the load status will be correctly reported; at least it worked for me with TC 10/NX 9.

www.nxjournaling.com
 
Hi

My code (above) with the change "ufs.Part.IsLoaded(thisComp.Name)"

gives changed output for native and TC but not correct for native and not for TC.

Note:
In my works we have 4 apps that I use as follows
2 graphics apps
1 nx native executed from a batch file to work in native with windows files
1 nx manger executed from a batch file to work on nx manager with
a web file enviroment called web nx manager.
after I finish the design and drawings I do a pre-release that transform the
drawing to othere file enviroment called TC web.

I do not know how all these configured.

So I let it as is and I ignor it until I know more about the configuration.

I'm very thank you for your eforts






 
Status
Not open for further replies.

Part and Inventory Search

Sponsor