Home Forums FDTD Script 3D Reply To: Script 3D

Paulo Lourenco

Hi again.

I really need help with this script for my 64bit license is almost finishing and I do not understand why this is not working. Layout script works when there is no tick on “Simulate using script” and when I test the script with a larger NumIterations, I can observe the effect of radius variable on the layout designer; looks like there is something wrong in file creation instructions…

Const NumIterations=1

For x=1 to NumIterations
ParamMgr.SetParam "radius",13-x*0.1

Call Sub_PowerAtCenterWavelength("ObservationArea1", x, True)


' Simulation and VB-post-data- analysis finished

'''''Start of sample code for the power calculation'''''''''

''''''''''''Calculate the Power At Center Wavelength'''''''''''''''''
'LineName - String - The name of the observation line
'IterationNum - Integer - The current iteration number in case of sweep simulation
'OutputIterationNum - Boolean - Indicate if the iteration number should be stored into the file.
'Sample: Call Sub_PowerAtCenterWavelength("ObservationLine1", nIteration, True)
Sub Sub_PowerAtCenterWavelength( AreaName, IterationNum, OutputIterationNum )
Dim error_msg 'for error handling
Dim fhs, ios 'for the output of the result
Dim power_val 'the Power At Center Wavelength
Dim observation_area 'The line object to the LineName.
Dim file_for_output 'The file name for storing the result.
Dim P_total

'Get the observation area.
Set observation_area = ObservePtMgr.GetObjFromID(AreaName)
'Calcualte the power at center wavelength.
P_total = observation_area.GetPowerTypeID(1)
power_val = observation_area.CalculatePowerRatioCWTotal()

'Save the result to the file.
If AppMgr.RunsInSimulator() = True Then
'Prepare the file for output.
Set fhs = CreateObject("Scripting.FileSystemObject")
file_for_output = GetOutputFileName("_PowerAtCenterWavelength.txt")
'Open for appending
Set ios = fhs.OpenTextFile(file_for_output, 8, True)

'Is there an error during the calculation?
' If observation_area.HasErrorsInPowerCalc() = True Then
' error_msg = observation_area.GetErrorMsg()
' ios.WriteLine( error_msg )
' Else
If OutputIterationNum Then
End If
ios.Close 'Close the file
End If

' End If
End Sub

'Helper function
'Postfix - String - will be appended to the file(of FDT) name.
'Sample: file_name = GetOutputFileName("ThePower.txt")
Function GetOutputFileName( Postfix )
Dim project_folder
Dim file_name

project_folder = AppMgr.GetProjectFolderName()
file_name = AppMgr.GetProjectFileName()
file_name = Left(file_name, Len(file_name) - 4)
file_name = file_name&PostFix
GetOutputFileName = project_folder&file_name
End Function
'''''End of sample code the for power calculatio

Whenever I run the script, no matter what value NumIterations has, I can not get past the attached print screen.
Any help would be much appreciated. Thank you up front…