AnsweredAssumed Answered

I am trying to set a total time for my transient study (which option works best)

Question asked by Kyle Thomson on Jul 6, 2020

Hi all,

 

     I am trying to set the total time and time steps for my transient thermal study using macros. I have been able to switch it to be transient from steady state but the two possible solutions I have tried don't seem to be functioning right. I will post the code below for reference. Will select a best answer, if a correct response is given.

 

'Should change the thermal study to transient
'will read the end conditions of the previously run study and use those as initial
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
Set ActiveDocObj = COSMOSWORKSObj.ActiveDoc()
Set StudyManagerObj = ActiveDocObj.StudyManager()
StudyManagerObj.ActiveStudy = 1
' Total_Time = 3600
'https://help.solidworks.com/2020/english/api/swsimulationapi/SolidWorks.Interop.cosworks~SolidWorks.Interop.cosworks.ICWThermalStudyOptions~TotalTime.html

Set ThermalOptionsObj = StudyObj.ThermalStudyOptions()
ThermalOptionsObj.SolverType = 3
ThermalOptionsObj.SolutionType = swsThermalSolutionType_e.swsThermalSolutionTypeTransient

 

 

'Option 1 from older code
' Total_Time = 100
' Time_Step = 5
' Step_Count = Total_Time / Time_Step

 

 

'Option 2 from solidworks
' ThermalOptions.TotalTime = 3600
' ThermalOptions.TimeIncrement = 600
Part.GraphicsRedraw2

Outcomes