cancel
Showing results for 
Search instead for 
Did you mean: 

Check if RSEvent is Active - how to?

Phenom
Phenom

To all,

 

my question is showing my very limited of vba programming but I have to ask. It is related to a previously posted query:

https://community.plm.automation.siemens.com/t5/NX-Programming-Customization/Checking-if-Solution-Ev...

 

While looping throught the Respponse Simulation (the solutions) (or the RSEvent)  I would like to check which event is active. The following function (property) should do it but I can't figure out how to set it up

 

Public Property ActiveEvent As RSEvent
	Get
	Set

 

Any help in expanding my very limited vba knowledge is welcome

Thanks

 

regards

 

JXB

 

 

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

Re: Check if RSEvent is Active - how to?

Siemens Pioneer Siemens Pioneer
Siemens Pioneer

Try this.

 

Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

Dim theSession As Session = Session.GetSession()
Dim workSimPart As CAE.SimPart = CType(theSession.Parts.BaseWork, CAE.SimPart)

Dim displaySimPart As CAE.SimPart = CType(theSession.Parts.BaseDisplay, CAE.SimPart)

'Change it as accordingly.

Dim solution1 As CAE.ResponseSimulation.Solution = CType(workSimPart.Simulation.ResponseSimulationManager.Solutions.FindObject("Response Simulation 1"), CAE.ResponseSimulation.Solution)

solution1.CheckObsoleteStatus()

Dim simSimulation1 As CAE.SimSimulation = CType(workSimPart.FindObject("Simulation"), CAE.SimSimulation)

'Make this response solution active.

simSimulation1.ResponseSimulationManager.Solutions.ActiveSolution = solution1

Dim rSEvent1 As CAE.ResponseSimulation.RSEvent

'Gets the active event.
rSEvent1 = solution1.ActiveEvent

Dim rSEvent2 As CAE.ResponseSimulation.RSEvent
rSEvent2 = solution1.CloneEvent(rSEvent1, Nothing)

'Sets the active event.

solution1.ActiveEvent = rSEvent1

End Sub
End Module

MAYAHTT
www.mayahtt.com

Re: Check if RSEvent is Active - how to?

Phenom
Phenom

thansk for that. The test below seems to work

 

Dim strRSSolName as String = "RespSim1"  'user Input
Dim pathAFUFile as String
Dim RespSimSolFound As CAE.ResponseSimulation.Solution
Dim RespSimEventFound As CAE.ResponseSimulation.RSEvent
Dim rSEvent1 As CAE.ResponseSimulation.RSEvent
				
Dim theSimPart As CAE.SimPart = CType(theSession.Parts.BaseWork, CAE.SimPart)

Dim theRespSimManager As NXOpen.CAE.ResponseSimulation.Manager = theSimPart.Simulation.ResponseSimulationManager	

Dim AllRespSimSolutions As CAE.ResponseSimulation.Solution() = theRespSimManager.Solutions.ToArray()

'Search for active event	
For Each myRespSimCol As CAE.ResponseSimulation.Solution In AllRespSimSolutions
If myRespSimCol.GetSolutionName = strRSSolName Then
 RespSimSolFound = myRespSimCol
  'Gets the active event.
  RespSimEventFound = RespSimSolFound.ActiveEvent
  theLW.WriteLine("the active event is: " & RespSimEventFound.GetEventName)
  Exit For
End if

End Function

 

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