Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

NX9 VB / Journal to Change Application / Module 1

Status
Not open for further replies.

charlesm80

Military
Joined
Aug 19, 2014
Messages
5
Location
US
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
 
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")​
 
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
 
Essentially, you don't.

NX programmer's help said:
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
 
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.
 
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
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top