Showing results for 
Search instead for 
Do you mean 
Solved! Go to solution

"Locked" Resp. Sim - How to check this status?

[ Edited ]

To all


In the Response Simulation Module once one has extracted some results (stress, force, etc) for a solution a small padlock appears in the manager, see attached, and one can no longer change the solution (damping, active modes, etc).


Is there a way of checking if a solution is "locked"? There sems to be nothing in the doc about this "status".





Question is (partially) related to a previous query: See


Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)
Accepted by topic author selex_ct
‎11-04-2015 03:16 AM

Re: "Locked" Resp. Sim - How to check this status?

An event is locked if one of three results files exist (.eef/.rs2/.afu).


The Response Sim is locked if any of the events in it are locked.


Unfortunately, there is no boolean property that directly indicates a lock status on either of these objects. This would be a good enhancement request...


You can use NXOpen.CAE.ResponseSimulation.RSEvent.GetResultFileName() to get the names of the result files for a particular event, then test to see if they exist:


Option Strict Off
Imports System

Imports NXOpen
Imports NXOpen.UF

Module RS_ModalResponseLock

    Dim theSession As Session = Session.GetSession()
    Dim theLw As ListingWindow = theSession.ListingWindow

    Dim theUI As UI = UI.GetUI
    Dim theNXMessageBox As NXMessageBox = theUI.NXMessageBox

    Sub Main()

        Dim simPart As CAE.SimPart = TryCast(theSession.Parts.BaseWork, CAE.SimPart)

        If simPart Is Nothing Then
            theNXMessageBox.Show("Invalid Part", NXMessageBox.DialogType.Error, "Work part must be a SIM part")
        End If


        Dim rsSolutionCollection As CAE.ResponseSimulation.SolutionCollection = simPart.Simulation.ResponseSimulationManager.Solutions

        For Each rsSolution As CAE.ResponseSimulation.Solution In rsSolutionCollection

            theLw.WriteLine("Response Simulation: " + rsSolution.GetSolutionName)

            Dim responseSimLockStatus As Boolean = False

            For Each rsEvent As CAE.ResponseSimulation.RSEvent In rsSolution.GetEvents()

                Dim eventName As String = rsEvent.GetEventName
                Dim eventLockStatus As Boolean = getEventLockedStatus(rsEvent)

                If eventLockStatus Then
                    eventName += " (locked)"
                    responseSimLockStatus = True
                End If

                theLw.WriteLine("  Event: " + eventName)

            Next rsEvent

            If responseSimLockStatus Then
                theLw.WriteLine("  - Response Simulation is locked")
            End If

        Next rsSolution

    End Sub

    Function getEventLockedStatus(ByVal rsEvent As CAE.ResponseSimulation.RSEvent) As Boolean

        getEventLockedStatus = False

        Dim modalResponseFilename As String = rsEvent.GetResultFileName(CAE.ResponseSimulation.RSEvent.ResultFileType.ModalResponse)
        Dim dynamicResponseFilename As String = rsEvent.GetResultFileName(CAE.ResponseSimulation.RSEvent.ResultFileType.DynamicResponse)
        Dim functionResponseFilename As String = rsEvent.GetResultFileName(CAE.ResponseSimulation.RSEvent.ResultFileType.FunctionResponse)

        If IO.File.Exists(modalResponseFilename) Then getEventLockedStatus = True
        If IO.File.Exists(dynamicResponseFilename) Then getEventLockedStatus = True
        If IO.File.Exists(functionResponseFilename) Then getEventLockedStatus = True

    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

    End Function

End Module

Re: "Locked" Resp. Sim - How to check this status?

Spot on JimB. Worth a lot more than 1 Kudo


Looks like I can "lift" your function getEventLockedStatus() as-is and I only need to add the following line in the code to display the GUI


If responseSimLockStatus = False Then ListToDisplaytoUser.Add(rsSolution.Name)


 It means that no further checks or Try..Catch loop when the main code is executed are required. Only "valid" resp sim solution are given in the list box.




Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)