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!

NX journal to pull attributes from Work part and display in Excel

Status
Not open for further replies.

Brian1321

Mechanical
Jul 6, 2021
1
Trying to pull Multiple attributes all from my workpart and bring it into Excel.
I can get it to pull one attribute but seem to be struggling to get anything more than one.

Code below. This only writes to Info window not excel:

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


Const CB_CUSTOMER As String = "CUSTOMER"
Dim attributeInfo As NXObject.AttributeInformation


If workPart.HasUserAttribute(CB_CUSTOMER, NXObject.AttributeType.String, -1) Then
attributeInfo = workPart.GetUserAttribute(CB_CUSTOMER, NXObject.AttributeType.String, -1)
lw.WriteLine("Job #: " & attributeInfo.StringValue)



End If



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
 
Replies continue below

Recommended for you


Try with below code

Code:
Dim allAttributes As NXOpen.NXObject.AttributeInformation()
Dim attribute As NXOpen.NXObject.AttributeInformation
allAttributes = WorkPart.GetUserAttributes()
For Each attribute In allAttributes
	'Check type and print the attibute info

Next

Regards,
Maddy

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor