×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX9 - Journal Code Help Needed.... again. :o)
2

NX9 - Journal Code Help Needed.... again. :o)

NX9 - Journal Code Help Needed.... again. :o)

(OP)
When in drafting, there seems to be some who like to see the borders around the views and some who don't. I thought it would be a good idea if I created a button to toggle the view borders on and off. I can record a journal to turn it on and one to turn it off, but I was wondering if someone could show me the way to use the "IF" correctly so one journal will turn it on or off depending on what the setting already is?

Just to make it clear, the same file will often be worked on by different people. That is why this is any kind of problem. Also, I find myself now working on something that I am constantly going back and forth turning the borders on and off.

RE: NX9 - Journal Code Help Needed.... again. :o)

2
No "If" is necessary.

CODE

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 undoMarkName As String = "toggle drafting view borders"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim preferencesBuilder1 As Drafting.PreferencesBuilder
        preferencesBuilder1 = workPart.SettingsManager.CreatePreferencesBuilder()

        preferencesBuilder1.ViewWorkflow.DisplayBorders = Not preferencesBuilder1.ViewWorkflow.DisplayBorders

        Dim nXObject1 As NXObject
        nXObject1 = preferencesBuilder1.Commit()

        preferencesBuilder1.Destroy()

        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 

www.nxjournaling.com

RE: NX9 - Journal Code Help Needed.... again. :o)

(OP)
Thanks cowski

This is awesome. I didn't know there was a toggle in code. Im gonna have to study this some to see how I get it to work for other things. lol

RE: NX9 - Journal Code Help Needed.... again. :o)

The code above works because the .DisplayBorders value is a boolean (true/false). The Not operation simply flips the value.

www.nxjournaling.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources