Start a new feature after switching a module (where that feature is compatible)

I was trying to Start a new feature after switching a module. for my case it was to start 'Move Face' after switching to 'Modeling' module. But I wanted the journal to stop after it just start the 'move face' command and stay there (for user to start working). So I recorded the journal for starting 'Move face' command. And added the coded to switch to modeling module. But when I play the edited journal, it just switches module, and does not start the moveface feature. Please suggest where I am doing wrong and what can be the solution. Thanks.


Imports System
Imports NXOpen
Imports NXOpen.UF

Module NXJournal
Sub Main (ByVal args() As String)

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work

Dim displayPart As NXOpen.Part = theSession.Parts.Display

' ----------------------------------------------
' Switch to MODELING Module
' ----------------------------------------------

Dim theUfSession As UFSession = UFSession.GetUFSession
' Dim lw As ListingWindow = theSession.ListingWindow
Dim theUI As UI = UI.GetUI
If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If

Dim currentModuleId As Integer
theUfSession.UF.AskApplicationModule(currentModuleId)

Select Case currentModuleId
Case Is = UFConstants.UF_APP_MODELING
'':::: take no action ::::
Case Else
theUI.MenuBarManager.ApplicationSwitchRequest("UG_APP_MODELING")
End Select

' ----------------------------------------------
' Menu: Insert->Synchronous Modeling->Move Face...
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

Dim nullNXOpen_Features_AdmMoveFace As NXOpen.Features.AdmMoveFace = Nothing

Dim admMoveFaceBuilder1 As NXOpen.Features.AdmMoveFaceBuilder = Nothing
admMoveFaceBuilder1 = workPart.Features.CreateAdmMoveFaceBuilder(nullNXOpen_Features_AdmMoveFace)

admMoveFaceBuilder1.FaceToMove.RelationScope = 511

admMoveFaceBuilder1.Motion.DistanceAngle.OrientXpress.AxisOption = NXOpen.GeometricUtilities.OrientXpressBuilder.Axis.Passive

admMoveFaceBuilder1.Motion.DistanceAngle.OrientXpress.PlaneOption = NXOpen.GeometricUtilities.OrientXpressBuilder.Plane.Passive

admMoveFaceBuilder1.Motion.AlongCurveAngle.AlongCurve.IsPercentUsed = True

admMoveFaceBuilder1.Motion.AlongCurveAngle.AlongCurve.Expression.RightHandSide = "0"

admMoveFaceBuilder1.Motion.AlongCurveAngle.AlongCurve.Expression.RightHandSide = "0"

admMoveFaceBuilder1.Motion.OrientXpress.AxisOption = NXOpen.GeometricUtilities.OrientXpressBuilder.Axis.Passive

admMoveFaceBuilder1.Motion.OrientXpress.PlaneOption = NXOpen.GeometricUtilities.OrientXpressBuilder.Plane.Passive

admMoveFaceBuilder1.FaceToMove.CoplanarEnabled = False

admMoveFaceBuilder1.FaceToMove.CoplanarAxesEnabled = False

admMoveFaceBuilder1.FaceToMove.CoaxialEnabled = False

admMoveFaceBuilder1.FaceToMove.EqualDiameterEnabled = False

admMoveFaceBuilder1.FaceToMove.TangentEnabled = False

admMoveFaceBuilder1.FaceToMove.SymmetricEnabled = False

admMoveFaceBuilder1.FaceToMove.OffsetEnabled = False

admMoveFaceBuilder1.FaceToMove.UseFaceBrowse = True

admMoveFaceBuilder1.Motion.DeltaEnum = NXOpen.GeometricUtilities.ModlMotion.Delta.ReferenceAcsWorkPart

theSession.SetUndoMarkName(markId1, "Move Face Dialog")

' ----------------------------------------------
' Menu: Tools->Journal->Pause Recording
' ----------------------------------------------

End Sub
End Module

NX journal doesn't support UI access to existing dialog menus. But you can achieve the same by coding custom menu or form or selection response (In this case).

This will start move face builder, keep a function to select input faces(I think earlier I shared the same thing for some sheet metal code you have requested ) for move, then provide the value through input box.

Dim nullNXOpen_Features_AdmMoveFace As NXOpen.Features.AdmMoveFace = Nothing

Dim admMoveFaceBuilder1 As NXOpen.Features.AdmMoveFaceBuilder = Nothing
admMoveFaceBuilder1 = workPart.Features.CreateAdmMoveFaceBuilder(nullNXOpen_Features_AdmMoveFace)

Regards,

Joe

Thanks Joe. I was trying to keep some everyday tools in the same place from different module. I was doing that by Macro's before which actually keep it open (with a user entry). But macro's are inconsistent with different versions on NX. And you are right, I can also do that using face selection. In that case getting user entry for extending value would be another set of codes, which I was trying to avoid. Anyway , thanks for the comments.

Regards,
MFJ

Try macro record instead of journal record. That might work for your request, Though I am not sure of it.

Regards,

Joe