Submitted by Kiennguyen511 on Sun, 03/08/2020 - 08:25
Forums:
hello,
I want to export the information in the parts list to an excel file. My idea is to use the Select Object function to select a table and then export the information in the table to an excel file. Can someone point me to this?
re: parts list to Excel
I don't currently have a journal that exports the parts list info to Excel, but here are a few journals that might help:
The journal at the link below writes the content of each cell of a tabular note to the info window. The parts list is a type of tabular note; given a parts list, a slightly modified version of this code should be able to write out all the info.
http://nxjournaling.com/comment/678#comment-678
The journal at the link below shows how to write some information to an Excel file.
http://nxjournaling.com/comment/4964#comment-4964
I have been able to export
I have been able to export info windown to excel file but I haven't done it yet to get information from the table to listingwindown.
To make it easier, I have the export function journal available in NX but it doesn't show any results.
My ideas are:
Select table => get information on windown => export to excel file.
Can you suggest helping me mix them up?
''''''''''''''''''''''''''''''''
'''' Seclect table
Function select_a_tabular_note(ByRef tabular_note As NXOpen.Tag) As _
Selection.Response
Dim message As String = "Tabular Note: "
Dim title As String = "Select a tabular note"
Dim scope As Integer = UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY
Dim response As Integer
Dim view As NXOpen.Tag
Dim cursor(2) As Double
Dim ip As UFUi.SelInitFnT = AddressOf init_proc
theUFSession.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
Try
theUFSession.Ui.SelectWithSingleDialog(message, title, scope, ip, Nothing,
response, tabular_note, cursor, view)
Finally
theUFSession.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
End Try
If response <> UFConstants.UF_UI_OBJECT_SELECTED Then
Return Selection.Response.Cancel
Else
Return Selection.Response.Ok
End If
End Function
Function init_proc(ByVal select_ As IntPtr, ByVal userdata As IntPtr) As _
Integer
' Selection initialization
Dim num_triples As Integer = 1
Dim mask_triples(0) As UFUi.Mask
mask_triples(0).object_type = UFConstants.UF_tabular_note_type
mask_triples(0).object_subtype = UFConstants.UF_tabular_note_section_subtype
mask_triples(0).solid_type = 0
theUFSession.Ui.SetSelMask(select_, UFUi.SelMaskAction.SelMaskClearAndEnableSpecific,
num_triples, mask_triples)
Return UFConstants.UF_UI_SEL_SUCCESS
End Function
'''''''''''''''''''''''''''''''''''''''''
Dim fileNameNoExt As String = IO.Path.GetFileNameWithoutExtension(workPart.FullPath)
Dim parentFolder As String = IO.Path.GetDirectoryName(workPart.FullPath)
Dim outputFile As String = IO.Path.Combine(parentFolder, fileNameNoExt & ".xls")
'***** comment out this section to append to existing file *****
'does file already exist? if so, delete it
If IO.File.Exists(outputFile) Then
Try
IO.File.Delete(outputFile)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Error deleting file:")
End Try
End If
'***** end of section *****
'use listing window to write to file and window
lw.SelectDevice(ListingWindow.DeviceType.FileAndWindow, outputFile)
lw.Open()
'write information to listing window
'' info from listing then export to excel file
lw.Close()
'flush file buffer by changing listing window device
lw.SelectDevice(ListingWindow.DeviceType.Window, "")
Kien
thank you for supporting
thank you for supporting
i will try it
Kien