×
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

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

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

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

(OP)

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



































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

(OP)
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

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

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

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

(OP)
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

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

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

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

(OP)

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

It sounds strong !!!

THANKS

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

(OP)
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

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

I had some time to revisit this. Try using the .Name instead of the .DisplayName.

CODE

ufs.Part.IsLoaded(thisComp.DisplayName)
ufs.Part.IsLoaded(thisComp.Name) 

www.nxjournaling.com

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

(OP)

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

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

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

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

(OP)
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






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