Submitted by JXB on Mon, 12/01/2014 - 02:03
Forums:
To all,
a couple of question on extracting information for an Response Simulation Event (RSEvent)
1. Extracting the RSEvent Type
it seems that one has to use the 'RSEventBuilder' rather than the 'RSEvent'. The following does not work (!)
For Each myRSEvent as CAE.ResponseSimulation.RSEventBuilder In solution1.GetEvents
theLW.WriteLine("Event Type is:" & myRSEvent.EventType)
Next myRSEvent
2. it seems that keyword:'GetResultFileName(RSEvent.ResultFileType)' returns result file name of specified type
RSEvent-->ResultFileType which is defined as an enumeration
'FunctionResponse': Result file to contain function response evaluation results, which extenstion is ".afu"
How do I set up the keyword?
Thanks
Regards
JXB
re: event type
I don't have a response simulation license, so the following code is untested:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module24
Sub Main(ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim mySimPart As CAE.SimPart
Try
mySimPart = CType(theSession.Parts.BaseWork, CAE.SimPart)
Catch ex As Exception
'not a sim part
Return
End Try
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
For Each tempEvent As CAE.ResponseSimulation.RSEvent In mySimPart.Simulation.ResponseSimulationManager.Events
Dim myRSEventBuilder As CAE.ResponseSimulation.RSEventBuilder = mySimPart.Simulation.ResponseSimulationManager.Events.CreateEventBuilder(tempEvent)
lw.WriteLine("Event type: " & myRSEventBuilder.EventType.ToString)
myRSEventBuilder.Destroy()
Next
lw.Close()
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY
End Function
End Module
RE: Event Type
Spot on. A minor tweak to incorporate the lines provided in my macro
Dim theRespSimManager As NXOpen.CAE.ResponseSimulation.Manager = theSimPart.Simulation.ResponseSimulationManager
For Each myRSEvent As CAE.ResponseSimulation.RSEvent In RespSimSolFound.GetEvents()
Dim myRSEventBuilder As CAE.ResponseSimulation.RSEventBuilder = theRespSimManager.Events.CreateEventBuilder(myRSEvent)
thelw.WriteLine("Event type: " & myRSEventBuilder.EventType.ToString)
myRSEventBuilder.Destroy()
Next
What is the purpose of the GetUnloadOption() function?
Thanks a lot. Much appreciated
JXB
Thanks
Regards
re: GetUnloadOption
The GetUnloadOption only applies if you compile your code to a .dll file; it instructs NX when to unload your custom code. It is in my template for a new project; normally I delete it before posting the code, but this time I forgot.