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!

Not Able to retrieve the value of Quantity - Integer

Status
Not open for further replies.

nxexplorer

Mechanical
Jun 23, 2010
84
I have made a journal for detecting whether the specific attribute already has its value or not.
When it run, there were still got the errors. Need help with the existing codes, below.
My focus is on getting the value of quantity of Integer data type.
******************************************************************************************
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim type As Int32 = UFConstants.UF_ATTR_any
Dim workpart As Part = theSession.Parts.Work

Dim title7 As String = "Item_QTY" 'The existing attribute's name in the part
Dim text_title7 As String = "Quantity" 'The text will be shown in The listing Window
Dim value7 As Integer
Dim thePartAttr7 As NXOpen.Tag = NXOpen.Tag.Null
ufs.Attr.AskPartAttribute(thePartAttr7)
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

If thePartAttr7 <> Tag.Null Then
ufs.Attr.FindAttribute(thePartAttr7, type, title7, realtype)
If realtype <> 0 Then
If realtype = UFConstants.UF_ATTR_integer Then
value7 = workpart.GetIntegerAttribute(title7)
lw.WriteLine( text_title7 + " :" + value7)
End If
Else
lw.WriteLine( text_title7 + " : Nilai Attribute belum ada ******************************************* Tolong dilengkapi!")
End If
End If
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

***************************************************************************************************

Any help is very appreciated, Thank you.
Regards,
Maryadi-Jakarta
 
Replies continue below

Recommended for you

I think I understand the requirement properly and made the below journal.
Below VB code check for the attribute "Item_QTY" and write it's value to listing window.
In case if the "Item_QTY" attribute is not available it gives an error message saying attribute is not in part.





Imports System
Imports NXOpen
Imports NXOpenUI

Module NXJournal
Sub Main()

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim theUi As UI = UI.GetUI()
Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow

Try

Dim qty As Integer = workPart.GetIntegerUserAttribute("Item_QTY", -1)
lw.Open()
lw.WriteFullline("The attribute Item_QTY value is : " + qty.ToString())

Catch ex As Exception

theUi.NXMessageBox.Show("Attribute Check", NXMessageBox.DialogType.Error, "Item_QTY Attribute is not available in this part")

End Try

End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module

 
Wow, this immediately solved the problem I'm having right now, the codes are great.
Thank you Ram K. Great help from you. I really appreciate this.[2thumbsup]

Also, I've emailed you about asking for help with C journaling, please check.
Thank you very much.

Regards,
Maryadi-Jakarta
 
You are welcome Maryadi-Jakarta
ramkan8@gmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor