Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Switch Part tool 4

Status
Not open for further replies.
Thanks for the new version, but unfortunately I get the following errors:

Syntax errors:
Line 466: 'GetUserAttributes' is not a member of 'NXOpen.Assemblies.Component'.
Line 485: 'GetUserAttributes' is not a member of 'NXOpen.Assemblies.Component'.
Line 781: 'GetUserAttributes' is not a member of 'NXOpen.Assemblies.Component'.
Line 791: 'StringValue' is not a member of 'NXOpen.NXObject.AttributeInformation'.
Line 798: 'StringValue' is not a member of 'NXOpen.NXObject.AttributeInformation'.
Line 1162: Method 'Public Sub newContextMenuStrip_Opening(sender As Object, e As System.EventArgs)' does not have the same signature as delegate 'Delegate Sub CancelEventHandler(sender As Object, e As System.ComponentModel.CancelEventArgs)'.
Line 1320: 'GetUserAttributes' is not a member of 'NXOpen.Assemblies.Component'.
Line 1328: 'StringValue' is not a member of 'NXOpen.NXObject.AttributeInformation'.
Line 1337: 'StringValue' is not a member of 'NXOpen.NXObject.AttributeInformation'.
Line 1346: 'StringValue' is not a member of 'NXOpen.NXObject.AttributeInformation'.

Does NXOpen have an other syntax in NX85? I'm working with NX7.5, windows 7 64bit
 
Hi MartijnH,

For the issue with "GetUserAttributes", that syntax is for NX 8.0 and above. To solve it, comment out
line 309
line 777 to 810
line 1317 to 1351
This will disable attribute functionality, but will at least get the program running.

For the issue on line 1162, to solve it, replace the "e As System.EventArgs" with "e As System.ComponentModel.CancelEventArgs".

Let me know if this helps. I will see what I can do to make attributes work with NX 7.5.

NX8.5 Win7SP1 64bit i7-3770K@4.3Ghz 16GB Quadro2000
 
I did not find the "e As System.EventArgs" in the actual VB code, but I commented line 1162 and that also works. Furthermore I had to comment line 466 and 485 also to get it working. I haven't tested it completely but it looks like everything is working. However, previews of the file does not work (it also did not work in version 1.1).

Thanks for this addon! I'm definitely going to use this.
 
Hi CNSZU,
for me the tool works without error in NX8.
The only problem is the performance.
My OS is XP 32 bit, maybe an 64 bit OS is different, or maybe the code can be improved.

Thank you...

Using NX 8 and TC9.1
 
Hi Cubalibre00,

For performance there is not much I can do about the coding. At the startup, by far the longest time is spent loading the Windows form elements. Changing to a different type of interface, like the NX Block Styler, MIGHT be faster, however that has limitations (no flyout menus). Anyway, with my PC specs, the tool loads in about 3 seconds regardless of the number of parts open in the NX session. When the tool is loaded, it works smoothly.

Here are some tips to improve performance:
- Use an SSD hard disk
- If you have NXOpen, convert the journal to a DLL file and use that instead of the journal. After the first use, any subsequent loadings will be instant (within the session).
- Upgrading to Win7 and/or .NET framework 4.5 MIGHT also improve performance.

NX8.5 Win7SP1 64bit i7-3770K@4.3Ghz 16GB Quadro2000
 
Thank you CNSZU for the tool developped.
At the moment I've the XP.
I will try to convert the .vb into .dll.

Thank you...

Using NX 8 and TC9.1
 
Hi CNSZU,

I found an other 'bug' using NX75. Your script does not show subassys (it does with version 1.1). It only shows one sublevel, but not the 3rd level. Is this somewhere in the options which I have to set?
 
Hi MartijnH,
Is the listing view set to "Standard List"? What .NET framework version do you have?

For debugging, replace the sub around line 1536 with:

Sub newContextMenuStrip_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs)
cNXSwitchPart.LW.Open()
cNXSwitchPart.LW.WriteLine("newContextMenuStrip_Opening1")
Cursor = Cursors.WaitCursor
cNXSwitchPart.LW.WriteLine("newContextMenuStrip_Opening2")
If cNXSwitchPart.bSearchResult = False Then
cNXSwitchPart.LW.WriteLine("newContextMenuStrip_Opening3")
For i As Integer = 0 To sender.Items.Count - 1
cNXSwitchPart.LW.WriteLine("newContextMenuStrip_Opening4")
Dim modifyMenuItem As ToolStripMenuItem
modifyMenuItem = sender.Items(i)
If modifyMenuItem.DropDown.Items.Count = 0 And modifyMenuItem.Tag.childlist.count > 0 Then
cNXSwitchPart.LW.WriteLine("newContextMenuStrip_Opening5")
modifyMenuItem.DropDown = AddMenuItems(modifyMenuItem.Tag, 0)
End If
Next
End If
Cursor = Cursors.Default
End Sub

Run it (a listing window should appear when you move the mouse over an assembly) and let me know the result of the listing window.

NX8.5 Win7SP1 64bit i7-3770K@4.3Ghz 16GB Quadro2000
 
oh my god...... OH......MY......GOD this thing is brilliant. I loaded 2 very large assemblies and searched for a material that probably 80 percent of all the parts are made from, it took a minute or two, but it did it.....
And HOW FAST is this one at starting up EH? Congratulation CNSZU ... awesome.. it worked faultlessly NX8[pc3][thumbsup2]
 
Hi moog2,

Thank you for testing it! And I'm very glad you're happy with it, if you want anything else to make it better, let me know:)

NX8.5 Win7SP1 64bit i7-3770K@4.3Ghz 16GB Quadro2000
 
Hi CNSZU,
I made a mistake interpreting your post about replacing e as System.EventArgs... Now I replaced the code in line 1536 and it now looks like: Sub newContextMenuStrip_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs). I also uncommented 1162, because that line calls this sub and now subassys do work again. However, I still do not see a preview, does this have to do something with .NET Framework? I have .NET 4.0 client.
 
Here is version 1.3 of the NX Switch Part tool.

Now it is possible to expand to the current displayed part by clicking a button on the status bar. Preview images should now work for NX 7.5.

Version 1.3 change log:

Added statusbar button to expand the menus to the displayed part (clicking again will cycle through multiple solutions if there are duplicate parts)
Added option for alphabetical listing of Standard List (requires restarting the tool)
Pressing ESC key will close tool windows
Fixed bug where the preview image was missing in NX 7.5
Fixed bug where the displayed part would sometimes change when closing the tool window
Fixed bug where a packed search list would show packed suppressed parts (now replaced with open parts)
Fixed other minor bugs

HOW TO INSTALL:
Download the attached "NXSwitchPart_1_3.rar" and extract (keep all files together in the same folder)
In NX: Customize ...> New User Command. With the new button, set Default style. Edit Action: Type: Journal File, browse to the vb file (choose NXSwitchPart75.vb for NX7.5)
Change button image > image name. Browse to the Window_sc.bmp file.
Use notepad to replace the path in the beginning of the journal (vb) file with the folder with the journal file and image files.

Additional details and instructions are found in the beginning of the vb file.

JOURNAL FILES:
NX8.5 Win7SP1 64bit i7-3770K@4.3Ghz 16GB Quadro2000
 
CNSZU

Thanks for your time creating this utility. This is a great addition to making NX more user friendly.

NxPerson

NX852/Teamcenter 8.3.3.5

 
Dear CNSZU.

First of all. Congratulations on the tool! It is superb!

Version 1.3 seems to have 2 bugs for us.

1. Some issue when pressing the expand to displayed part:

9SsS20h.png


Full error message
Code:
See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at fMain.tsddbExpand_Click(Object sender, EventArgs e) in C:\Users\jevtho04\AppData\Local\Temp\NXJournals10148\journal.vb:line 1863
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.StatusStrip.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18052 built by: FX45RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
ManagedLoader
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.0.0
    CodeBase: file:///C:/Program%20Files/Siemens/NX80/ugii/managed/ManagedLoader.DLL
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18044 built by: FX45RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18060 built by: FX45RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18060 built by: FX45RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
NXOpen.Utilities
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.0.0
    CodeBase: file:///C:/Program%20Files/Siemens/NX80/ugii/managed/NXOpen.Utilities.DLL
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18047 built by: FX45RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18021 built by: FX45RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
journal
    Assembly Version: 0.0.0.0
    Win32 Version: 0.0.0.0
    CodeBase: file:///C:/Users/jevtho04/AppData/Local/Temp/NXJournals10148/journal.dll
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 10.0.0.0
    Win32 Version: 11.0.50709.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
NXOpen
    Assembly Version: 8.0.3.4
    Win32 Version: 8.0.3.4
    CodeBase: file:///C:/Program%20Files/Siemens/NX80/ugii/managed/NXOpen.DLL
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
Accessibility
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Descriptive part name is set to description.

2. It does not pack the components either:
0ZcL0Hl.png


NX8.0.3.4 TC 9.1.2.3.
HP Z820 / Quadro2000
 
Hi

I have tried to get the latest version to run on NX7.5 and NX8.5 however both return this error.

ERROR: \\rocfp02\users\Roc-MIS\simon.wright\My Documents\NX_Switch_Part_1_3open_part.bmp

Any ideas what is causing this.

Cheers

Si

Best regards

Simon NX 7.5.4.4 MP8 and NX 8.5 (native) - TC 8
 
Hi Thor,

I'm sorry, I don't know why you're getting these problems, so I need your help in finding the solution.

1. expand to display part issue:
Does the error occur for only some displayed parts or all?
Does the error occur for just this assembly or all assemblies?

Please replace the code between
Private Sub tsddbExpand_Click(sender As Object, e As EventArgs) Handles tsddbExpand.Click
and
End Sub
with

Code:
 Dim bFound As Boolean = False

        For Each c As ContextMenuStrip In openedContextMenuStripList
            c.Close()
        Next

        cNXSwitchPart.LW.Open()
        cNXSwitchPart.LW.WriteLine("start expand")
        cNXSwitchPart.LW.WriteLine("cNXSwitchPart.CycleIndex1: " & cNXSwitchPart.CycleIndex)

        cNXSwitchPart.CycleIndex += 1
        If cNXSwitchPart.CycleIndex > cNXSwitchPart.DisplayPartPathList.Count - 1 Then cNXSwitchPart.CycleIndex = 0

        cNXSwitchPart.LW.WriteLine("cNXSwitchPart.DisplayPartPathList.Count: " & cNXSwitchPart.DisplayPartPathList.Count)
        cNXSwitchPart.LW.WriteLine("cNXSwitchPart.CycleIndex2: " & cNXSwitchPart.CycleIndex)

        For i As Integer = 0 To cNXSwitchPart.DisplayPartPathList(cNXSwitchPart.CycleIndex).Count - 1

            cNXSwitchPart.LW.WriteLine("path: " & i & " " & cNXSwitchPart.DisplayPartPathList(cNXSwitchPart.CycleIndex)(i).name)

        Next


        Dim bToolStripMenuItem As New ToolStripMenuItem

        For i As Integer = 0 To cNXSwitchPart.DisplayPartPathList(cNXSwitchPart.CycleIndex).Count - 2 'do not include the last component (displayed part)

            cNXSwitchPart.LW.WriteLine("i: " & i)

            If i = 0 Then
                For j As Integer = 0 To tsMain.Items.Count - 1

                    cNXSwitchPart.LW.WriteLine("j1: " & j)

                    If tsMain.Items(j).Tag.name = cNXSwitchPart.DisplayPartPathList(cNXSwitchPart.CycleIndex)(i).name Then

                        cNXSwitchPart.LW.WriteLine("showdropdown1")

                        Dim aToolStripSplitButton As ToolStripSplitButton = tsMain.Items(j)
                        aToolStripSplitButton.ShowDropDown()

                        bToolStripMenuItem.DropDown = aToolStripSplitButton.DropDown

                    End If
                Next


            Else
                For j As Integer = 0 To bToolStripMenuItem.DropDownItems.Count - 1

                    cNXSwitchPart.LW.WriteLine("j2: " & j)

                    If bToolStripMenuItem.DropDownItems(j).Tag.name = cNXSwitchPart.DisplayPartPathList(cNXSwitchPart.CycleIndex)(i).name Then

                        cNXSwitchPart.LW.WriteLine("showdropdown2")

                        bToolStripMenuItem = bToolStripMenuItem.DropDownItems(j)
                        bToolStripMenuItem.ShowDropDown()
                        Exit For
                    End If
                Next
            End If
        Next

        For i As Integer = 0 To bToolStripMenuItem.DropDownItems.Count - 1
            If bToolStripMenuItem.DropDownItems(i).Tag.displayPart = True Then

                cNXSwitchPart.LW.WriteLine("select1")

                bToolStripMenuItem.DropDownItems(i).Select()
                AllMouseEnter(bToolStripMenuItem.DropDownItems(i).Tag)
                bFound = True
                Exit For

            End If
        Next

        If cNXSwitchPart.DisplayPartPathList(cNXSwitchPart.CycleIndex).Count = 1 Then

            cNXSwitchPart.LW.WriteLine("Count = 1")

            For i As Integer = 0 To tsMain.Items.Count - 1

                cNXSwitchPart.LW.WriteLine("i3: " & i)

                If tsMain.Items(i).Tag.displayPart = True Then

                    cNXSwitchPart.LW.WriteLine("select2")

                    tsMain.Items(i).Select()
                    AllMouseEnter(tsMain.Items(i).Tag)
                    Exit For
                End If
            Next
        End If

        If cNXSwitchPart.DisplayPartPathList.Count = 1 Then tsddbExpand.Enabled = False

Run the journal again, press the button to expand to the troubled display part to recreate the error (a listing windows should open), then post the contents of the listing window here or upload it as a text file.

2. Packed list problem:
Have you selected the option "Packed" for listing view in the options? (right click the window to access it)
If you have, if you then do a search, does the search list show the parts as packed? (note down what the tool window title says)
This option should affect both Standard and Search List.


NX8.5 Win7SP1 64bit i7-3770K@4.3Ghz 16GB Quadro2000
 
Hi Simon,

You need to add a backslash "\" after the path in the journal file. So in your case it should be ...My Documents\NX_Switch_Part_1_3

NX8.5 Win7SP1 64bit i7-3770K@4.3Ghz 16GB Quadro2000
 
Dear CNSZU

Thanks for the prompt response.

1. It happens for all displayed parts in NX Managed. It works in a native assembly. I suppose the error is somewhere in our TC config.


Code:
start expand
cNXSwitchPart.CycleIndex1: -1
cNXSwitchPart.DisplayPartPathList.Count: 0
cNXSwitchPart.CycleIndex2: 0


2. No, I was not aware of the right click possibility. It is working without issues. [peace]

NX8.0.3.4 TC 9.1.2.3.
HP Z820 / Quadro2000
 
Hi Thor,

I'm surprised you even got it running under TC, since I'm unable to test it in that mode. So unfortunately I can't fix that issue, unless someone can "convert" the code to work with TC.

NX8.5 Win7SP1 64bit i7-3770K@4.3Ghz 16GB Quadro2000
 
Status
Not open for further replies.
Back
Top