Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

journal help

Status
Not open for further replies.

moog2

Mechanical
Jan 16, 2007
441
Could someone help me with a simple jourmal file.
I'd like to "up-rev" my drafting attribute "REV" with a simple push of a button.
I'd think its a simple "if - then" type thing, where if the value is ORIG then it changes to A, if A then B, if C then D, all the way to Z (omitting I,O,Q,U) , then, if Z then ORIG.
Any help appreciated, (or similar examples ripe for modifying)
 
Replies continue below

Recommended for you

someone......please......

I tried to use an existing journal, and add what seemed like something suitable, but it doesn't work
can someone get it to work?

Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities

Module report_value_of_specific_part_attribute

Dim s As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim lw As ListingWindow = s.ListingWindow()

Sub Main()

Dim dispPart As Part = s.Parts.Display()

Dim title As String = "REV"
Dim value As String = ""

find_part_attr_by_name(dispPart, title, value)


End Sub


Sub Main()



If value = "ORIG" Then

dispPart.SetAttributr("REV" , "A")

' else

end if

End Sub



End Module
 
The following was coded for NX 8, it should work on other versions but there are no guarantees...

Below is one way to do what you ask.

Code:
Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.UI
Imports NXOpen.Utilities

Module report_value_of_specific_part_attribute

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()
    Dim lw As ListingWindow = theSession.ListingWindow()

    Sub Main()

        lw.Open()
        Dim dispPart As Part = theSession.Parts.Display()

        Dim title As String = "REV"
        Dim value As String = ""
        Dim charVal As Integer

        Try
            value = dispPart.GetStringAttribute(title)
            value = value.ToUpper
        Catch ex As Exception
            lw.WriteLine("error: " & ex.Message)
            Exit Sub
        End Try

        If String.IsNullOrWhiteSpace(value) Then
            lw.WriteLine("revision attribute has no value")
            Exit Sub
        End If

        If value = "ORIG" Then

            Try
                dispPart.SetAttribute(title, "A")
            Catch ex As Exception
                lw.WriteLine("error: " & ex.Message)
            End Try

        Else

            If value.Length > 1 OrElse value < "A" OrElse value > "Z" Then
                lw.WriteLine("error: invalid revision value")
                Exit Sub
            End If

            Select Case value
                Case "H", "N", "P", "T"
                    'skip values of "I", "O", "Q", "U"
                    charVal = Asc(value) + 2
                    value = Chr(charVal)
                Case "Z"
                    lw.WriteLine("current revision is 'Z', modify code to allow for more revisions")
                    Exit Sub
                Case Else
                    charVal = Asc(value) + 1
                    value = Chr(charVal)
            End Select

            Try
                dispPart.SetAttribute(title, value)
                lw.WriteLine("new revision value is: " & value)
            Catch ex As Exception
                lw.WriteLine("error setting attribute: " & ex.Message)
            End Try

        End If

    End Sub


End Module

www.nxjournaling.com
 
Cowski,
That works faultlessly in NX8 & NX9 thanks very much, just what I was after...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor