To all
I have a small programme which creates rms results (stress or force) for a given list of event and list of groups. Program seems to work as intended but I have noticed the following problem. Consider the following steps done by the user
1. In a brand new NX session (start NX, open sim file). Assume everything is there in term of resp. simulation events, results, etc. It’s all “good”.
2. Start the GUI for the programme
3. Select groups, events and the result type
4. Press ‘OK’ to start creating the results
While the programme loops (through the groups and events as intended) it does not manage to create the rms results requested HOWEVER If I manually create an rms result (say stress) the normal way (In NX) then re-do steps 2-4 described above then the program seems to work. In other words it does create the rms result requested.
It seems that by doing a “cold” start my programme lacks some initialisation. By doing at least 1 rms result the normal way, NX is somehow initializing something that is picked up by my programme.
I appreciate this is not an easy thing to explain. I have posted the function below I am using
Does anyone know if "calls" to variables like CAE.ResponseSimulation.PeakValueEvaluationSettingBuilder or CAE.ResponseSimulation.RmsResultsEvaluationSettingBuilder requires more than I have put?
Thanks
Regards
Function CreatePeakRMSResult(theRSEvent As CAE.ResponseSimulation.RSEvent, _
stheEventType as String, _
stheResQttyType As String, _
stheRS2FilePath As String, _
thearrFEElm() as CAE.FEElement) As Boolean
Dim iError As Integer = 0
Dim workSimPart As CAE.SimPart = CType(theSession.Parts.BaseWork, CAE.SimPart)
Dim simSimulation1 As CAE.SimSimulation = workSimPart.Simulation()
Dim peakValueEvaluationSettingBuilder1 As CAE.ResponseSimulation.PeakValueEvaluationSettingBuilder
Dim peakValueEvaluationSetting1 As CAE.ResponseSimulation.PeakValueEvaluationSetting
Dim rmsResultsEvaluationSettingBuilder1 As CAE.ResponseSimulation.RmsResultsEvaluationSettingBuilder
Dim rmsResultsEvaluationSetting1 As CAE.ResponseSimulation.RmsResultsEvaluationSetting
'Dim combinationEvaluationOptions1 As CAE.ResponseSimulation.CombinationEvaluationOptions
Dim dataComponent1(3) As CAE.ResponseSimulation.DirectionDataComponent
dataComponent1(0) = CAE.ResponseSimulation.DirectionDataComponent.X
dataComponent1(1) = CAE.ResponseSimulation.DirectionDataComponent.Y
dataComponent1(2) = CAE.ResponseSimulation.DirectionDataComponent.Z
dataComponent1(3) = CAE.ResponseSimulation.DirectionDataComponent.Vonmises
Dim nXObject1 As NXObject
Dim sEventAndResType As String
Try
If stheEventType = "Transient" Then
peakValueEvaluationSettingBuilder1 = simSimulation1.ResponseSimulationManager.EvaluationSettingManager. _
CreatePeakValueEvaluationSettingBuilder(Nothing)
'Variable to make reading of the code easier
sEventAndResType = stheEventType & "-" & stheResQttyType
If sEventAndResType = "Transient-Force" Then peakValueEvaluationSettingBuilder1.ResultType = CAE.ResponseSimulation.EvaluationResultType.ElementForce
If sEventAndResType = "Transient-Stress" Then peakValueEvaluationSettingBuilder1.ResultType = CAE.ResponseSimulation.EvaluationResultType.Stress
'combinationEvaluationOptions1 = peakValueEvaluationSettingBuilder1.CombinationOptions
peakValueEvaluationSettingBuilder1.SetOutputElements(thearrFEElm)
peakValueEvaluationSettingBuilder1.SetDataComponents(dataComponent1)
'peakValueEvaluationSettingBuilder1.SetDescriptionString(description1)
nXObject1 = peakValueEvaluationSettingBuilder1.Commit()
peakValueEvaluationSetting1 = CType(nXObject1, CAE.ResponseSimulation.PeakValueEvaluationSetting)
theSession.Post.UnloadResultFile(stheRS2FilePath)
theRSEvent.EvaluatePeakValueResults(peakValueEvaluationSetting1)
peakValueEvaluationSetting1.Destroy()
peakValueEvaluationSettingBuilder1.Destroy()
Else 'stheEventType = "Random"
rmsResultsEvaluationSettingBuilder1 = simSimulation1.ResponseSimulationManager.EvaluationSettingManager. _
CreateRmsResultsEvaluationSettingBuilder(Nothing)
If sEventAndResType = "Random-Force" Then rmsResultsEvaluationSettingBuilder1.ResultType = CAE.ResponseSimulation.EvaluationResultType.ElementForce
If sEventAndResType = "Random-Stress" Then rmsResultsEvaluationSettingBuilder1.ResultType = CAE.ResponseSimulation.EvaluationResultType.Stress
'combinationEvaluationOptions1 = rmsResultsEvaluationSettingBuilder1.CombinationOptions
rmsResultsEvaluationSettingBuilder1.SetOutputElements(thearrFEElm)
rmsResultsEvaluationSettingBuilder1.SetDataComponents(dataComponent1)
nXObject1 = rmsResultsEvaluationSettingBuilder1.Commit()
rmsResultsEvaluationSetting1 = CType(nXObject1, CAE.ResponseSimulation.RmsResultsEvaluationSetting)
theSession.Post.UnloadResultFile(stheRS2FilePath)
theRSEvent.EvaluateRmsResults(rmsResultsEvaluationSetting1)
rmsResultsEvaluationSetting1.Destroy()
rmsResultsEvaluationSettingBuilder1.Destroy()
CreatePeakRMSResult = True
End if
Catch ex As Exception
'---- Enter your exception handling code here -----
iError += 1
CreatePeakRMSResult = False
'Throw ex
End Try
End Function