Showing results for 
Search instead for 
Did you mean: 

solve the active solution using NXOpen


Hi Team,

when i used this piece of code to solve all solutions it works fine...

for (int i = 0; i < 5; i++)


NXOpen.CAE.SimSolveManager abc = NXOpen.CAE.SimSolveManager.GetSimSolveManager(thesess);

int xc = 0;

int ys = 0;

int ys1 = 0;

abc.SolveAllSolutions(NXOpen.CAE.SimSolution.SolveOption.Solve, NXOpen.CAE.SimSolution.SetupCheckOption.CompleteCheckAndOutputErrors, NXOpen.CAE.SimSolution.SolveMode.Background, false, out xc, out ys, out ys1);




But i need to solve only the active solution or the particular solution so I used the foloowing two API's:


activesol.Solve(NXOpen.CAE.SimSolution.SolveOption.Solve, NXOpen.CAE.SimSolution.SetupCheckOption.CheckAndStopAtFirstError);




abc.SolveChainOfSolutions(toSolve, NXOpen.CAE.SimSolution.SolveOption.Solve, NXOpen.CAE.SimSolution.SetupCheckOption.CheckAndStopAtFirstError, NXOpen.CAE.SimSolution.SolveMode.Background, out xc, out ys, out ys1);


to solve the selected solution. But when I am using these two method my script is not waiting till the solution is solved and proceed further without waiting untill to solve the solution.


Can anyone knows how can I wait till my solution is solved or I get to know that the solution is solved.



Re: solve the active solution using NXOpen


I'm not sure, but i think there will be a nastran.exe or some other process running on the system. just check if this process is still running


sub Main()


        'Check for finished process
        System.Threading.Thread.Sleep(1000) ' Pause for xx seconds...
        For ii As Integer = 0 To 100 'max wait time in seconds
            If CheckIfRunning("step214ug") = False Then
                Echo("Translations finished, process not detected", 1, False)
                Exit For
                Echo("Translation running...", 1, False)
                System.Threading.Thread.Sleep(1000) ' Pause for xx seconds...
            End If


end Sub

    Function CheckIfRunning(strProcessName As String) As Boolean

        Dim p() As Process
        p = Process.GetProcessesByName(strProcessName) 'automatically adds (".exe")
        If p.Length > 0 Then
            ' Process is running
            Return True
            ' Process is not running
            Return False
        End If
    End Function

Re: solve the active solution using NXOpen

Honored Contributor
Honored Contributor