Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Journal to extract attributes from components? 1

Status
Not open for further replies.

Kenja824

Automotive
Nov 5, 2014
949
We are looking for a fast way to open an assembly and find all the components with the "CYL_Code" attribute and export certain other attributes from just those components to an excel sheet.

If anyone has a journal that does something similar to that, I would very much appreciate it if you would share it.

Thanks!
 
Replies continue below

Recommended for you

Try something like this. It will not export to Excel but it will process all parts in assembly.

Code:
Option Strict Off
 
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies
Imports System.Collections.Generic
 
Public class PList1

	Public Property Part_Name As String
	Public Property Attrib_Name As String
	Public Property Value_Name As String

Public Sub New(ByVal PartN As String, ByVal AttrN As String, ByVal ValN As String)

	Part_Name = PartN
	Attrib_Name = AttrN
	Value_Name = ValN

End Sub

End Class


 
Module NXJournal
 
	Public theSession As Session = Session.GetSession()
	Public ufs As UFSession = UFSession.GetUFSession()
	Public lw As ListingWindow = theSession.ListingWindow
	Dim PartList1 as New list (of PList1) ()
	Dim List1 as New List (of String)
	
Sub Main()
	
	Dim workPart As Part = theSession.Parts.Work
	Dim dispPart As Part = theSession.Parts.Display
 
	lw.Open
	
	Try

		Dim c As ComponentAssembly = dispPart.ComponentAssembly

		if not IsNothing(c.RootComponent) then

			ReportComponentChildren(c.RootComponent, 0)
			lw.writeline(" ")
			ReportComponentChildren2(c.RootComponent, 0)
			
		else

			lw.WriteLine("Part has no components")

		end if
		
		Catch e As Exception
	
			theSession.ListingWindow.WriteLine("Failed: " & e.ToString)
		
	End Try
	
	if Not IsNothing(Partlist1) AndAlso Partlist1.Count > 0 Then
		
		partlist1.sort(AddressOf Comparer)		
	
		lw.writeline(" ")
		lw.writeline("--------------------------------------")
		lw.writeline("| File name | Attribute name | Value |")
		lw.writeline("--------------------------------------")
		lw.writeline(" ")

		for each comp_ as PList1 in Partlist1

			lw.writeline(comp_.Part_Name & " | " & comp_.Attrib_Name & " | " & comp_.Value_Name ) 
			
		next		
		
	end if
	
	lw.Close
 
End Sub
 
'*****************************************************************************************
' Empty run
'*****************************************************************************************
Sub reportComponentChildren( ByVal comp As Component, ByVal indent As Integer)

	Dim workPart As Part = theSession.Parts.Work
	Dim dispPart As Part = theSession.Parts.Display

	For Each child As Component In comp.GetChildren()
	
	Dim MyPart As Part = child.Prototype.OwningPart

	Try

		if child.IsSuppressed = true then

			lw.writeline("   Error: " & child.DisplayName & ".prt" & " -> " & "File closed")
			Continue for
			
		end if
		
			Catch e1 As Exception
				theSession.ListingWindow.WriteLine("Failed: " & e1.ToString)

	end try
	

	If LoadComponent(child) Then

							

	Else

		'component could not be loaded

	End If

	reportComponentChildren(child, indent+1)
	   
	 
	Next

End Sub
	
'*****************************************************************************************
' Changing file name 
'*****************************************************************************************

Sub reportComponentChildren2( ByVal comp As Component, ByVal indent As Integer)

	Dim workPart As Part = theSession.Parts.Work
   	Dim dispPart As Part = theSession.Parts.Display
	
	For Each child As Component In comp.GetChildren()

	Dim MyPart As Part = child.Prototype.OwningPart 

	Try

		if child.IsSuppressed = true then

			'lw.writeline("Error: " & child.DisplayName & ".prt" & "   " & "File closed")
			'exit sub
			'exit for
			Continue for
			
		end if
		
		Catch e1 As Exception
			
			theSession.ListingWindow.WriteLine("Failed: " & e1.ToString)

	end try



 	If LoadComponent(child) Then
	
		Dim File_name as string	
		Dim My_attrib as String 
		File_name = child.DisplayName()
		
		try

			My_attrib = mypart.GetStringAttribute("CYL_Code")
			
			'lw.writeline("File name: " & child.Name)
			'lw.writeline("CYL_Code: " & My_atrib)
			
			Catch ex01 As NXException

			If ex01.ErrorCode = 512008 Then
			
				My_attrib = "-"

			Else

				lw.WriteLine("error: " & ex01.ErrorCode & ", " & ex01.Message)

			End If

		end try
	
		'lw.writeline(child.Name & " , " & My_atrib) 
	
		if My_attrib = "" or My_attrib = " " or My_attrib = "-" then 
			
		else 
		
			if not list1.contains(child.name) then 
				
				list1.add(child.name)
				lw.writeline("")	
				lw.writeline("component name: " & child.Name)
				
		        Dim attr_info() As NXObject.AttributeInformation = myPart.GetUserAttributes
		
				For Each ainfo As NXObject.AttributeInformation In attr_info
				
					'if type is string, do something with the value
					
					If ainfo.Type = NXObject.AttributeType.String Then
					
						lw.WriteLine(ainfo.title & " = " & ainfo.StringValue)
						Partlist1.add(new PList1(child.name, ainfo.title, ainfo.StringValue))
						
					End If
					
				Next
		
		
			end if
		
		end if	
		
		'lw.writeline("component name: " & child.Name & "-> " & File_name )
		'lw.writeline("")





	Else
	
		'component could not be loaded
				
	End If 	

			reportComponentChildren2(child, indent + 1)
			
		Next
		
	End Sub

'**********************************************************
Private Function Comparer(ByVal x As Plist1, ByVal y As Plist1) As Integer

	Dim result As Integer = x.Part_name.CompareTo(y.Part_name)

	If result = 0 Then

		result = x.Attrib_Name.CompareTo(y.Attrib_Name)
		
	End If

	Return result

End Function

'**********************************************************
' Function loading components
'**********************************************************

Private Function LoadComponent(ByVal theComponent As Component) As Boolean
 
	Dim thePart As Part = theComponent.Prototype.OwningPart
 
	Dim partName As String = ""
	Dim refsetName As String = ""
	Dim instanceName As String = ""
	Dim origin(2) As Double
	Dim csysMatrix(8) As Double
	Dim transform(3, 3) As Double
 
	Try
			
		If thePart.IsFullyLoaded Then
		
			'component is fully loaded
				
		Else
			
			'component is partially loaded
				
		End If
			
		Return True
			
		Catch ex As NullReferenceException
		'component is not loaded
			
		Try
			
			ufs.Assem.AskComponentData(theComponent.Tag, partName, refsetName, instanceName, origin, csysMatrix, transform)
 
			Dim theLoadStatus As PartLoadStatus
			theSession.Parts.Open(partName, theLoadStatus)
 
			If theLoadStatus.NumberUnloadedParts > 0 Then
 
				Dim allReadOnly As Boolean = True
			
				For i As Integer = 0 To theLoadStatus.NumberUnloadedParts - 1
				
					If theLoadStatus.GetStatus(i) = 641058 Then
							'read-only warning, file loaded ok
							
					Else
						
						'641044: file not found
						lw.WriteLine("Error: " & partname & "   " & "File not found")
						allReadOnly = False
							
					End If

				Next

				If allReadOnly Then
				
					Return True
					
				Else
				
					'warnings other than read-only...
					Return False
						
				End If
				
			Else
			
				Return True
			
			End If
 
			Catch ex2 As NXException
			
				if ex2.message = "File not found" then 
				
					lw.WriteLine("Error: " & partname & "   " & "File not found")		
					
				else
				
					lw.WriteLine("Error: " & partname & "   " & ex2.Message)
					
				end if
				
			Return False
				
		End Try
			
	Catch ex As NXException
		
		'unexpected error
		lw.WriteLine("error: " & ex.Message)
		Return False
			
	End Try
 
End Function

'**********************************************************
Public Function GetUnloadOption(ByVal dummy As String) As Integer

	Return Session.LibraryUnloadOption.Immediately

End Function
'**********************************************************
 
End Module

With best regards
Michael
 
Thanks niedzviedz

I have been trying to make this work. I have uncommented some LW lines trying to get the info I want to write to a window at least but I cant seem to get the My_Attrib code to display the CYL_CODE attribute string.

I havent tested it, but as I was writing this, I had the thought maybe it is looking for the CYL_CODE attribute in the actual component. What I would need is for it to look for that attribute in the components at the Assembly level. For it is an attribute we only add at the assembly level. Would this be the problem? And could you tell me what i need to change please?
 
What are values for CYL_CODE? Every file in assembly has this attribute - CYL_CODE or only few of them?
Uncoment this: (after end try)

Code:
'lw.writeline(child.Name & " , " & My_atrib)

and change it to something like this:

Code:
lw.writeline("Part name: " & child.Name) 
lw.writeline("CYL_Code: " & My_atrib)

And write if that result is what You need. If so You can delete:

Code:
		if My_attrib = "" or My_attrib = " " or My_attrib = "-" then 
			
		else 
		
			if not list1.contains(child.name) then 
				
				list1.add(child.name)
				lw.writeline("")	
				lw.writeline("component name: " & child.Name)
				
		        Dim attr_info() As NXObject.AttributeInformation = myPart.GetUserAttributes
		
				For Each ainfo As NXObject.AttributeInformation In attr_info
				
					'if type is string, do something with the value
					
					If ainfo.Type = NXObject.AttributeType.String Then
					
						lw.WriteLine(ainfo.title & " = " & ainfo.StringValue)
						Partlist1.add(new PList1(child.name, ainfo.title, ainfo.StringValue))
						
					End If
					
				Next
		
		
			end if
		
		end if	
		
		'lw.writeline("component name: " & child.Name & "-> " & File_name )
		'lw.writeline("")

With best regards
Michael
 
In playing around with it, I find that it is closer to the correct result without that last code you said to delete.

I was also able to add a second attribute it would list. That is good.

Though the Info Window will list all of the components, it only seems to show the attributes for the components with the CYL_CODE attribute. Which is fine. It would be better I think if it only listed the components with that attribute, but this is fine. You have done so much already.

The only problem however, is for this to work, it seems the attribute "CYL_CODE" must be a part of the actual component file. This attribute will not be in any of the component files but will be added to the components only at the assembly level. Currently this journal does not find those.

I apologize for the hassle and do appreciate your help.

-----------------------------------------------

To give you a better understanding of why this is needed....

When our designers model up tools, they will often have different power clamps and hydraulic cylinders they will use. They will be adding the attribute "CYL_CODE" to each cylinder component they have added to their tool. They will fill this attribute out according to the order they open and close when the tool runs. The first clamp to close will get "1", the second to close will get "2" etc...

Someone else here who uses what is called an SDP program, needs to know what order the clamps open and close, so by the designers adding this attribute at the assembly level, we are looking to turn this journal into a way to gather specific attributes for each cylinder or clamp and export the info to excel so she can know which ones open and close first.

I have some code that will export attributes to excel already. Only that exports the work part attributes instead of component attributes. I plan on playing with it and trying to find a way to get it to work with this journal once I get this one returning the right info I need.
 
I don't know if I understand You correctly, but below is updated code:

Code:
Option Strict Off
 
Imports System
Imports System.IO
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Assemblies

 
Public class PList1

	Public Property Part_Name As String
	Public Property Attrib_Name As String
	Public Property Value_Name As String

Public Sub New(ByVal PartN As String, ByVal AttrN As String, ByVal ValN As String)

	Part_Name = PartN
	Attrib_Name = AttrN
	Value_Name = ValN

End Sub

End Class

 
Module NXJournal
 
	Public theSession As Session = Session.GetSession()
	Public ufs As UFSession = UFSession.GetUFSession()
	Public theUISession As UI = UI.GetUI
	Public lw As ListingWindow = theSession.ListingWindow
	Dim PartList1 as New list (of PList1) ()
	Dim List1 as New List (of String)
	
Sub Main()
	
	Dim workPart As Part = theSession.Parts.Work
	Dim dispPart As Part = theSession.Parts.Display

	Dim saveFileName As String
	Dim saveDialog As New System.Windows.Forms.SaveFileDialog
	Dim objExcel As Object
	Dim objWorkbook As Object
	Dim excelFileExists As Boolean = False
	Dim objWorksheet As Object
	Dim colPartname As Integer = 1
	Dim colAttribname As Integer = 2
	Dim colValueNumber As Integer = 3
	Dim rowNumber As Integer = 1
	
	lw.Open
	
	Dim My_attrib1 as String
	
	try

			My_attrib1 = workpart.GetStringAttribute("CYL_Code")
			
			
			Catch ex011 As NXException

			If ex011.ErrorCode = 512008 Then
			
				My_attrib1 = "-"

			Else

				lw.WriteLine("error: " & ex011.ErrorCode & ", " & ex011.Message)

			End If

		end try
	
			
		if My_attrib1 = "" or My_attrib1 = " " or My_attrib1 = "-" then 
			
		else 
		
			if not list1.contains(workpart.name) then 
				
				list1.add(Workpart.name)

				
		        Dim attr_info() As NXObject.AttributeInformation = workPart.GetUserAttributes
		
				For Each ainfo As NXObject.AttributeInformation In attr_info
				
					'if type is string, do something with the value
					
					If ainfo.Type = NXObject.AttributeType.String and ainfo.title = "CYL_Code" Then
					
						'lw.WriteLine(ainfo.title & " = " & ainfo.StringValue)
						Partlist1.add(new PList1(workpart.name, ainfo.title, ainfo.StringValue))
						
					End If
					
				Next
		
		
			end if
		
		end if	
		
	Try

		Dim c As ComponentAssembly = dispPart.ComponentAssembly

		if not IsNothing(c.RootComponent) then

			ReportComponentChildren(c.RootComponent, 0)
			lw.writeline(" ")
			ReportComponentChildren2(c.RootComponent, 0)
			
		else

			lw.WriteLine("Part has no components")

		end if
		
		Catch e As Exception
	
			theSession.ListingWindow.WriteLine("Failed: " & e.ToString)
		
	End Try
	
	if Not IsNothing(Partlist1) AndAlso Partlist1.Count > 0 Then
		
		partlist1.sort(AddressOf Comparer)		
	
		lw.writeline(" ")
		lw.writeline("--------------------------------------")
		lw.writeline("| File name | Attribute name | Value |")
		lw.writeline("--------------------------------------")
		lw.writeline(" ")
		
		for each comp_ as PList1 in Partlist1
			
			lw.writeline(comp_.Part_Name & " | " & comp_.Attrib_Name & " | " & comp_.Value_Name ) 
						
		next	
		
		
		With saveDialog
			.DefaultExt = "xlsx"
			.FileName = "My data"
			.Filter = "MS Excel Spreadsheets (*.xlsx) | *.xlsx | All Files (*.*) | *.*"
			.FilterIndex = 1
			.OverwritePrompt = True
			.Title = "Select a file where you'd like to save the exported data."
		End With
		
		savedialog.showdialog()
		saveFileName = saveDialog.FileName

		If saveFileName = "Exported Data" Then

			MsgBox("You failed to select a save file. Exiting the macro.")
			Exit Sub

		End If

		objExcel = CreateObject("Excel.Application")

		If objExcel Is Nothing Then

			theUISession.NXMessageBox.Show("Error", theUISession.NXMessageBox.DialogType.Error, "Could not start Excel, journal exiting")
			Exit Sub

		End If

		If File.Exists(saveFileName) Then
			excelFileExists = True
			objWorkbook = objExcel.Workbooks.Open(saveFileName)
			objWorksheet = objWorkbook.Sheets.Add

		Else

			objWorkbook = objExcel.Workbooks.Add
			objworkbook.saveas(SaveFilename)
			objWorksheet = objWorkbook.Sheets(1)

		End If
			
		
		objWorksheet.cells(rowNumber, colPartname).Value = "Part Name"
		objWorksheet.cells(rowNumber, colAttribname).Value = "Atrribute name"
		objWorksheet.cells(rowNumber, colValueNumber).Value = "Value"
		
		
		for each comp_ as PList1 in Partlist1
			
			'lw.writeline(comp_.Part_Name & " | " & comp_.Attrib_Name & " | " & comp_.Value_Name ) 
			rowNumber += 1	
			
            objWorksheet.cells(rowNumber, colPartname).Value = comp_.Part_Name
            objWorksheet.cells(rowNumber, colAttribname).Value = 	comp_.Attrib_Name
			objWorksheet.cells(rowNumber, colValueNumber).Value = comp_.Value_Name	
			
		next		
		
		
		objWorksheet.columns("A:M").entirecolumn.autofit
		objWorkbook.save
		objWorkbook.close
		objExcel.quit()
		Cleanup(objWorksheet, objWorkbook, objExcel)
		MsgBox("Completed the extraction successfully! Check " & saveFileName & " for the data.")
		
	end if
	

	
	lw.Close
 
End Sub


Sub Cleanup(ParamArray objs As Object())

	GC.Collect()
	GC.WaitForPendingFinalizers()

	For Each obj As Object In objs

		System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
		obj = Nothing

	Next

End Sub
 
'*****************************************************************************************
' Empty run
'*****************************************************************************************
Sub reportComponentChildren( ByVal comp As Component, ByVal indent As Integer)

	Dim workPart As Part = theSession.Parts.Work
	Dim dispPart As Part = theSession.Parts.Display

	For Each child As Component In comp.GetChildren()
	
	Dim MyPart As Part = child.Prototype.OwningPart

	Try

		if child.IsSuppressed = true then

			lw.writeline("   Error: " & child.DisplayName & ".prt" & " -> " & "File closed")
			Continue for
			
		end if
		
			Catch e1 As Exception
				theSession.ListingWindow.WriteLine("Failed: " & e1.ToString)

	end try
	

	If LoadComponent(child) Then

							

	Else

		'component could not be loaded

	End If

	reportComponentChildren(child, indent+1)
	   
	 
	Next

End Sub
	
'*****************************************************************************************
' Changing file name 
'*****************************************************************************************

Sub reportComponentChildren2( ByVal comp As Component, ByVal indent As Integer)

	Dim workPart As Part = theSession.Parts.Work
   	Dim dispPart As Part = theSession.Parts.Display
	
	For Each child As Component In comp.GetChildren()

	Dim MyPart As Part = child.Prototype.OwningPart 

	Try

		if child.IsSuppressed = true then

			'lw.writeline("Error: " & child.DisplayName & ".prt" & "   " & "File closed")
			'exit sub
			'exit for
			Continue for
			
		end if
		
		Catch e1 As Exception
			
			theSession.ListingWindow.WriteLine("Failed: " & e1.ToString)

	end try



 	If LoadComponent(child) Then
	
		Dim File_name as string	
		Dim My_attrib as String 
		File_name = child.DisplayName()
		
		try

			My_attrib = mypart.GetStringAttribute("CYL_Code")
			
			'lw.writeline("File name: " & child.Name)
			'lw.writeline("CYL_Code: " & My_atrib)
			
			Catch ex01 As NXException

			If ex01.ErrorCode = 512008 Then
			
				My_attrib = "-"

			Else

				lw.WriteLine("error: " & ex01.ErrorCode & ", " & ex01.Message)

			End If

		end try
	
		'lw.writeline(child.Name & " , " & My_atrib) 
	
		if My_attrib = "" or My_attrib = " " or My_attrib = "-" then 
			
		else 
		
			if not list1.contains(child.name) then 
				
				list1.add(child.name)
				'lw.writeline("")	
				'lw.writeline("component name: " & child.Name)
				
				
				
		        Dim attr_info() As NXObject.AttributeInformation = myPart.GetUserAttributes
		
				For Each ainfo As NXObject.AttributeInformation In attr_info
				
					'if type is string, do something with the value
					
					If ainfo.Type = NXObject.AttributeType.String and ainfo.title = "CYL_Code" Then
					
						'lw.WriteLine(ainfo.title & " = " & ainfo.StringValue)
						Partlist1.add(new PList1(child.name, ainfo.title, ainfo.StringValue))
						
					End If
					
				Next
		
		
			end if
		
		end if	
		
		'lw.writeline("component name: " & child.Name & "-> " & File_name )
		'lw.writeline("")


	Else
	
		'component could not be loaded
				
	End If 	

			reportComponentChildren2(child, indent + 1)
			
		Next
		
	End Sub

'**********************************************************
Private Function Comparer(ByVal x As Plist1, ByVal y As Plist1) As Integer

	Dim result As Integer = x.Part_name.CompareTo(y.Part_name)

	If result = 0 Then

		result = x.Attrib_Name.CompareTo(y.Attrib_Name)
		
	End If

	Return result

End Function

'**********************************************************
' Function loading components
'**********************************************************

Private Function LoadComponent(ByVal theComponent As Component) As Boolean
 
	Dim thePart As Part = theComponent.Prototype.OwningPart
 
	Dim partName As String = ""
	Dim refsetName As String = ""
	Dim instanceName As String = ""
	Dim origin(2) As Double
	Dim csysMatrix(8) As Double
	Dim transform(3, 3) As Double
 
	Try
			
		If thePart.IsFullyLoaded Then
		
			'component is fully loaded
				
		Else
			
			'component is partially loaded
				
		End If
			
		Return True
			
		Catch ex As NullReferenceException
		'component is not loaded
			
		Try
			
			ufs.Assem.AskComponentData(theComponent.Tag, partName, refsetName, instanceName, origin, csysMatrix, transform)
 
			Dim theLoadStatus As PartLoadStatus
			theSession.Parts.Open(partName, theLoadStatus)
 
			If theLoadStatus.NumberUnloadedParts > 0 Then
 
				Dim allReadOnly As Boolean = True
			
				For i As Integer = 0 To theLoadStatus.NumberUnloadedParts - 1
				
					If theLoadStatus.GetStatus(i) = 641058 Then
							'read-only warning, file loaded ok
							
					Else
						
						'641044: file not found
						lw.WriteLine("Error: " & partname & "   " & "File not found")
						allReadOnly = False
							
					End If

				Next

				If allReadOnly Then
				
					Return True
					
				Else
				
					'warnings other than read-only...
					Return False
						
				End If
				
			Else
			
				Return True
			
			End If
 
			Catch ex2 As NXException
			
				if ex2.message = "File not found" then 
				
					lw.WriteLine("Error: " & partname & "   " & "File not found")		
					
				else
				
					lw.WriteLine("Error: " & partname & "   " & ex2.Message)
					
				end if
				
			Return False
				
		End Try
			
	Catch ex As NXException
		
		'unexpected error
		lw.WriteLine("error: " & ex.Message)
		Return False
			
	End Try
 
End Function

'**********************************************************
Public Function GetUnloadOption(ByVal dummy As String) As Integer

	Return Session.LibraryUnloadOption.Immediately

End Function
'**********************************************************
 
End Module

For export to excel I used code from this Link.

With best regards
Michael
 
Please be patient with me as I sometimes have a hard time explaining things. I tend to make it more confusing.

Imagine there are two assemblies and both are using the same power clamp component in our library. In either assembly, if you right click on that component and select "properties", you will see all of its attributes.

Now lets say in Assembly "A" you open that components properties and add a new attribute. From assembly "A" you will always see that attribute for that component. But in assembly "B" if you look at its properties, all you will see is its original attributes. You wont see the new attribute.

When we run this code, we need it to look at the components attributes from the assembly level and not the component level.

For instance, I have three components that I have added a CYL_CODE attribute to from my assembly level. These three components have the attribute filled out with "1", "2" and "3". I also created a nothing component I named "TEST" and while I was in that file, I gave it the attribute "CYL_CODE" and filled it in as XYZ. This way I can see where the code is finding the attribute.

Currently this code is finding the TEST with the XYZ attribute, but it does not find any of the components that have the attribute assigned at the assembly level. I need it to look at the components from the assembly level instead of opening them and looking at their original attributes.

---------------------------------------

As for this new code....

I added the lw.writeline code (As it was giving me a blank window when I ran it) that I am looking for to test if it is working right. I also added a second attribute "My_Attrib2" to the code. I dont think I got this right...

attr_code-1_yptwsx.png


When I run it, I get this result...

attr_code-2_dcambc.png


Other than the code finds the attribute from the component level and not at the assembly level, I got it to return the second attribute but it doesnt give the attributes result. (Cant think of what you call that part of the attribute). It should be coming back with...

Part name: TEST
CYL_Code: XYZ
DB_PART_TYPE: CORP_tool

And if the code was working for what I need, it would find three more components.

I suppose I should add a second test component with a different attribute result to see if it finds both or just one.

Again, I do apologize for the hassle this is turning into for you and I do appreciate your help.
 
Awesome cowski. This works great. Thank you so much.

And thank you niedzviedz for all the work you put into helping me as well. I really appreciate that.


Now to the next part. Printing to excel. lol I am going to try and figure it out for myself. I really hope for once I wont have to come back begging for someone to save my sanity again.
 
Hey cowski

I updated your journal to gather the attributes I need. 6 of them total. Your code made that very easy. Thanks. lol I really wasnt going to bother you unless I really couldnt figure it out, but since I struggle with the simplest of code, I am figuring that is already a foregone conclusion. lol

I think the easiest way to explain this is through pics.

Currently when I run the journal, I will get this result in the info window....

attr_code-1_vye0ye.png


When I copy and paste it to excel it is like this...

attr_code-2_qw1emn.png


I am told they want the information presented like this... (As it would be easy for them to sort it how they need and not get the information mixed up between components.)

attr_code-3_oj6svc.png


These are the attributes I added to the journal...

attr_code-4_j7lyt7.png


If this is something that will take a lot of time, dont worry about it. I could set up an excel sheet to copy the info to and use formulas on a second tab to get arrange it how we want. Im just trying to make this as simple for them as possible when they use it.

Thanks :)
 
What version of NX are you using these days? There are some relatively new functions that make it easier to connect to Excel; I'd like to use those if they are available to you.

www.nxjournaling.com
 
NX1872

Is there a trick to getting emails when I get replies again. I used to and they just stopped. Now I only see replies if I go and look at the thread.
 
If you go to the "my stuff" tab (upper right of the browser window) and choose "my profile", you will find the default notification options. Also, you can turn notifications on/off for individual threads. With a thread open, look at the right side (above the ads); there is a "notify me" link that you can use to turn it on/off for the current thread.

www.nxjournaling.com
 
Yeah, I have looked at those before. They are already set to notify me but I still dont get any emails when I get replies. However, I went ahead and updated my profile and saved it. Maybe it just needed that to reset it or something. We will see how it goes.

Ken
My brain is like a sponge. A sopping wet sponge. When I use it, I seem to lose more than I soak in.
 
This last one is doing something weird. Even with four cylinders having these attributes, it is only writing the last one on row 2 with titles on row 1.

My guess is it is finding all the cylinders but writing each cylinders info over top the last always on the first row under the titles. Either that or it is only writing the info to the last cylinder found.

I have a file with about 30 units (assemblies) in it. I attributed cylinders in just the first three units to test this and it gave me the info for the cylinder in unit 003. So I added attributes to a cylinder in unit 004 and ran it and it only gave me the info in unit 004.

Ken
My brain is like a sponge. A sopping wet sponge. When I use it, I seem to lose more than I soak in.
 
Awesome. Works great now. Thank you very much.



Ken
My brain is like a sponge. A sopping wet sponge. When I use it, I seem to lose more than I soak in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor