×
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 VB / Journal to Change Application / Module

NX9 VB / Journal to Change Application / Module

NX9 VB / Journal to Change Application / Module

(OP)
Has anyone managed to find some VB code to change from one application to another?
Specifically, I'd like to change to the Modeling application before taking some other actions.
Recording a journal sets an undo mark but doesn't actually record the change.
I stumbled across the fact that I can change to Drafting by opening a drawing sheet but getting to Modeling (or Gateway might work) has eluded me.

Thanks

RE: NX9 VB / Journal to Change Application / Module

Sounds like you want the ApplicationSwitchRequest method.

www.nxjournaling.com

RE: NX9 VB / Journal to Change Application / Module

(OP)
Thank you!
I'm sure it would help if I could get our IT to install the help files, but knowing the right words to search for sure helps too.
For anyone else looking for this (I found the question unanswered in a lot of places), a working line of code is:

UI.GetUI().MenuBarManager.ApplicationSwitchRequest("UG_APP_MODELING")

RE: NX9 VB / Journal to Change Application / Module

(OP)
Followup question:
This line of code is not executed until the journal finishes (verified by placing a MsgBox after this line). I want it to execute immediately so I can orient the view afterwords in the same journal.
Does anyone know how to do that?

Thanks

RE: NX9 VB / Journal to Change Application / Module

Essentially, you don't.

Quote (NX programmer's help)


When the running journal or program finishes, the system will attempt to switch into the target application. The current application does not change immediately.

However, that probably won't prevent you from doing what you want to do.

www.nxjournaling.com

RE: NX9 VB / Journal to Change Application / Module

(OP)
What I want to do is go to modeling, orient and fit the view and then save, so that the part preview is set nicely.
With the Journal set to just go to modeling and orient, it will work two or three times and then start failing as it tries to orient before changing applications (from drafting). It would be less frustrating if it were consistent instead of teasing me the first few times. Exiting NX and restarting resets the "two or three" counter.
Oh well, it works as a macro so I'll just leave it as that. I was trying to move all of our macros and GRIPs into VB.
Thank you for the information.

RE: NX9 VB / Journal to Change Application / Module

The following code will orient the modeling view whether you are in the modeling or drafting application.

CODE

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim theUfSession As UFSession = UFSession.GetUFSession()
        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work

        Const undoMarkName As String = "orient modeling view"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Dim currentDisplayState As Integer
        theUfSession.Draw.AskDisplayState(currentDisplayState)

        theUfSession.Draw.SetDisplayState(1)
        workPart.ModelingViews.WorkView.Orient(View.Canned.Trimetric, View.ScaleAdjustment.Fit)

        theUfSession.Draw.SetDisplayState(currentDisplayState)

    End Sub

End Module 

www.nxjournaling.com

RE: NX9 VB / Journal to Change Application / Module

(OP)
Thank you very much once again!
With your code I can insert my save steps between your Orient and final SetDisplayState and it achieves my goal.

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