Re: CST MWS vba script parameter sweep ASCII export
來源:edatop
更新時(shí)間:2024-08-13
閱讀:
Hi everybody
I have a little problem with the CST VB.
I design a model in CST MWS. Know
I want to performe a Parameter-Sweep.
I choose a userdefined output.
Cause I want to analyze some data in matlab,
I want, what CST save for expample the energy in a ascii file.
A new file for every run of the sweep.
But this is not working.
Do you have a idea?
The code:
Code:
Code:
Option ExplicitSub ParameterSweepWatch(action As Integer) 'Please define actions for the parameter sweep watch here. Select Case action Case 0 'Please define actions before the parametersweep starts. Case 1 'Please define actions after each calculation. Dim zaehler As Integer Dim Dateiname As String Dim filename As String Dim Fileendung As String Dim strwert As String Dim wertdouble As Double wertdouble= ParameterSweep.GetValueOfVaryingParameter() strwert = CStr(wertdouble) filename = "I:\simulation-Output\File-" Fileendung = ".txt" Dateiname = SelectTreeItem ("1D Results\Energy\Energy [5]") With ASCIIExport .Reset .FileName (Dateiname) .Mode ("FixedNumber") .Execute End With Case 2 'Please define actions after the parametersweep has finished. End SelectEnd SubSub Main() ParameterSweepWatch 0 ParameterSweepWatch 1 ParameterSweepWatch 2End Sub
PS:
I found the answer.
It was to easy!
' userdefined watch for parameter sweep
Code:
Option ExplicitSub ParameterSweepWatch(action As Integer)'Please define actions for the parameter sweep watch here.Select Case action Case 0 'Please define actions before the parametersweep starts. Case 1 'Please define actions after each calculation. Dim zaehler As Integer Dim Dateiname As String Dim filename As String Dim Fileendung As String Dim strwert As String Dim wertdouble As Double wertdouble = ParameterSweep.GetValueOfVaryingParameter(0) Parametername = ParameterSweep.GetNameOfVaryingParameter(0) strwert = CStr(wertdouble) filename = "I:\simulation-Output\File-" Fileendung = ".txt" Dateiname =filename & Parametername & strwert & Fileendung SelectTreeItem ("1D Results\Energy\Energy [5]") With ASCIIExport .Reset .FileName (Dateiname) .Mode ("FixedNumber") .Step(100) .Execute End With Case 2 'Please define actions after the parametersweep has finished.End SelectEnd SubSub Main() ParameterSweepWatch 0 ParameterSweepWatch 1 ParameterSweepWatch 2End Sub
what is your problem?
you can get your results directly from file-export-ascii format
may that i understand from your question,if not forgive me for misunderstand