Import assembly from excel/text file
Import assembly from excel/text file
(OP)
All more experienced users and or Journal(ists) please help :)
I have a problem with some assembly work. I have a bunch of files (a lot)on disk (parts) that need to be assembled.
Assembly structure is possible to get in Excel/text format with relatively small effort. Used NX version is NX7.5
Is there a quick way to import assemblies according to excel list so that native nx could read all listed part files from one directory? End results would be then easy to modify later if some parts change before importing them to Teamcenter later.
Importing to TC is not an option yet because TC installation does not exist yet for this location. Have to set wheels in motion before installation can be started.
Examples and perhaps excisting journals would be helpful.
Thanks in advance
NH
I have a problem with some assembly work. I have a bunch of files (a lot)on disk (parts) that need to be assembled.
Assembly structure is possible to get in Excel/text format with relatively small effort. Used NX version is NX7.5
Is there a quick way to import assemblies according to excel list so that native nx could read all listed part files from one directory? End results would be then easy to modify later if some parts change before importing them to Teamcenter later.
Importing to TC is not an option yet because TC installation does not exist yet for this location. Have to set wheels in motion before installation can be started.
Examples and perhaps excisting journals would be helpful.
Thanks in advance
NH





RE: Import assembly from excel/text file
CODE
Option Strict Off Imports System Imports System.IO Imports System.Windows.Forms Imports NXOpen Module Module1 Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Sub Main() If theSession.Parts.Display Is Nothing Then MsgBox("Active part required") Exit Sub End If Dim openFileDialog1 As New OpenFileDialog() openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" openFileDialog1.FilterIndex = 1 openFileDialog1.RestoreDirectory = True If openFileDialog1.ShowDialog() = DialogResult.OK Then Dim line As String Using sr As StreamReader = New StreamReader(openFileDialog1.FileName) Try line = sr.ReadLine() While Not line Is Nothing If File.Exists(line) Then Dim componentName As String = Path.GetFileNameWithoutExtension(line).ToUpper AddComponent(line, "", componentName) End If line = sr.ReadLine() End While Catch E As Exception MessageBox.Show(E.Message) End Try End Using End If End Sub Sub AddComponent(ByVal compPath As String, ByVal refSet As String, Optional ByVal compName As String = Nothing) Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Add Component") Dim nErrs1 As Integer nErrs1 = theSession.UpdateManager.DoUpdate(markId1) Dim basePoint1 As Point3d = New Point3d(0.0, 0.0, 0.0) Dim orientation1 As Matrix3x3 orientation1.Xx = 1.0 orientation1.Xy = 0.0 orientation1.Xz = 0.0 orientation1.Yx = 0.0 orientation1.Yy = 1.0 orientation1.Yz = 0.0 orientation1.Zx = 0.0 orientation1.Zy = 0.0 orientation1.Zz = 1.0 Dim partLoadStatus1 As PartLoadStatus Dim component1 As Assemblies.Component component1 = workPart.ComponentAssembly.AddComponent(compPath, refSet, compName, basePoint1, orientation1, 1, partLoadStatus1, True) partLoadStatus1.Dispose() End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination End Function End Modulewww.nxjournaling.com
RE: Import assembly from excel/text file
I tested with some parts and though reporting might help in some cases this was exactly what was needed. We will put this to more serious use soon.
RE: Import assembly from excel/text file
Last post about my request was great!
Here is another nut to crack. Your code makes thigs easier but there is just too many parts and of course shared by many assemblies.
Below is a simplified example of a multilevel BOM exported to a text file from previous system. Assuming that all child parts are in the same directory and no assembly levels exist, would it be possible to generate the assembly structure from the text file using existing parts? Levels of assembly can be marked differently if the format is a problem. Generating empty child assemblies components against a text file with existing template file and populating them with existing parts is way beyond me.
Now with that previous journal it is possible to assemble one level at the time. More convenient way would be to have multiple levels in one text file imported once. I do not know how easy this would be, but with multiple levels there should be a report telling if no part was found from the import folder.
How to do this, first generate all assembly files and then populate them with parts or start from lowest level assy first and then progress to higher levels... Assemblies could be marked with A to distinguish which ones to create and so on.
MAIN_ASSY.PRT
. FIRST_LEVEL_CHILD_ASSY.PRT
. . SECOND_LEVEL_ASSY1.PRT
. . . bolt.prt
. . . Plate.prt
. . . Flat_Washer-prt
. . . 1_8_BSP_STR_Grease_Nipple.prt
. . . bolt.prt
. . . Flat_Washer.prt
. . . Flat_Washer.prt
. . . nut.prt
. . . Flat_Washer.prt
. . . nut.prt
. . . THIRD_LEVEL_ASSY1.PRT
. . . . Beam1.prt
. . . . Beam2.prt
. . . . Beam1.prt
. . Second_Level_assy2.prt
. . . Flat_Washer.prt
. . . nut_20.prt
. . . Hose1.prt
Do you think you could help me out with this?
Cheers
-NH
RE: Import assembly from excel/text file
www.nxjournaling.com
RE: Import assembly from excel/text file
It has correctly handled my (limited) test cases; however, I do not claim to have tested for every possibility. Create some fictional test cases of your own to try it out. This journal will create new files and add components to existing files, do NOT use it without some testing first. Use at your own risk, please report any bugs you find and I will try to sort them out.
Reporting in this initial version is minimal.
https://www.dropbox.com/s/uh0nogiri2mceqp/create_a...
www.nxjournaling.com
RE: Import assembly from excel/text file
Thank you...
Using NX 8 and TC9.1
RE: Import assembly from excel/text file
Can you provide a sample text file BOM that shows the problem you are having?
www.nxjournaling.com
RE: Import assembly from excel/text file
which is the syntax to put more then one of the same component ?
Thank you...
Using NX 8 and TC9.1
RE: Import assembly from excel/text file
www.nxjournaling.com
RE: Import assembly from excel/text file
www.nxjournaling.com
RE: Import assembly from excel/text file
Then, if I've 30 screws of the same part number, I need to create 30 lines of this part number ?
If yes, you can implement in the journal the support for the quantity ?
Example :
MAIN_ASSY.PRT
. FIRST_LEVEL_CHILD_ASSY.PRT,5
. . SECOND_LEVEL_ASSY1.PRT,1
. . . bolt.prt,1
. . . Plate.prt
. . . Flat_Washer-prt
. . . 1_8_BSP_STR_Grease_Nipple.prt
. . . bolt.prt
. . . Flat_Washer.prt
. . . Flat_Washer.prt
. . . nut.prt
. . . Flat_Washer.prt
. . . nut.prt
. . . THIRD_LEVEL_ASSY1.PRT
. . . . Beam1.prt
. . . . Beam2.prt
. . . . Beam1.prt
. . Second_Level_assy2.prt
. . . Flat_Washer.prt
. . . nut_20.prt
. . . Hose1.prt
Thank you...
Using NX 8 and TC9.1
RE: Import assembly from excel/text file
RE: Import assembly from excel/text file
That would work to place a tabular note, but would not create an assembly file for you.
www.nxjournaling.com