# NX 2412
# Journal created by antoi on Tue Nov 18 14:01:45 2025 Eastern Standard Time
#
import math
import NXOpen
import NXOpen.CAE
def main(args) : 

    theSession  = NXOpen.Session.GetSession() #type: NXOpen.Session
    workSimPart = theSession.Parts.BaseWork
    displaySimPart = theSession.Parts.BaseDisplay
    # ----------------------------------------------
    #   Menu: Analysis->Solve...
    # ----------------------------------------------
    markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
    
    theSession.SetUndoMarkName(markId1, "Solve Dialog")
    
    markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Solve")
    
    theSession.DeleteUndoMark(markId2, None)
    
    markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Solve")
    
    theCAESimSolveManager = NXOpen.CAE.SimSolveManager.GetSimSolveManager(theSession)
    
    psolutions1 = [NXOpen.CAE.SimSolution.Null] * 1 
    simSimulation1 = workSimPart.FindObject("Simulation")
    simSolution1 = simSimulation1.FindObject("Solution[Solution 1]")
    psolutions1[0] = simSolution1
    numsolutionssolved1, numsolutionsfailed1, numsolutionsskipped1 = theCAESimSolveManager.SolveChainOfSolutions(psolutions1, NXOpen.CAE.SimSolution.SolveOption.Solve, NXOpen.CAE.SimSolution.SetupCheckOption.CompleteDeepCheckAndOutputErrors, NXOpen.CAE.SimSolution.SolveMode.Background)
    
    theSession.DeleteUndoMark(markId3, None)
    
    theSession.SetUndoMarkName(markId1, "Solve")
    
    markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Activate Solution")
    
    simSolution2 = simSimulation1.FindObject("Solution[Solution_Normal_Modes]")
    simSolutionStep1 = simSolution2.FindObject("SolutionStep[Subcase - Normal Modes 1]")
    simSolution2.ActiveStep = simSolutionStep1
    
    # ----------------------------------------------
    #   Menu: Analysis->Solve...
    # ----------------------------------------------
    markId5 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")
    
    theSession.SetUndoMarkName(markId5, "Solve Dialog")
    
    markId6 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Solve")
    
    theSession.DeleteUndoMark(markId6, None)
    
    markId7 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Solve")
    
    psolutions2 = [NXOpen.CAE.SimSolution.Null] * 1 
    psolutions2[0] = simSolution2
    theSession.Post.PostviewDelete(9)
    
    numsolutionssolved2, numsolutionsfailed2, numsolutionsskipped2 = theCAESimSolveManager.SolveChainOfSolutions(psolutions2, NXOpen.CAE.SimSolution.SolveOption.Solve, NXOpen.CAE.SimSolution.SetupCheckOption.CompleteDeepCheckAndOutputErrors, NXOpen.CAE.SimSolution.SolveMode.Background)
    
    theSession.DeleteUndoMark(markId7, None)
    
    theSession.SetUndoMarkName(markId5, "Solve")
    
    # ----------------------------------------------
    #   Menu: Tools->Automation->Journal->Stop Recording
    # ----------------------------------------------
    
if __name__ == '__main__':
    main(sys.argv[1:])