'Language "WWB-COM"
Option Explicit
Sub Main()
' Define and initialize variables
Dim i As Integer
Dim scalingFactor As Double
Dim project As Object
Dim exportPath As String
Dim fileName As String
Dim SL, SW, SH, Mt, PL, PW, ML, MW, InL, InW, k As Double
' Initialize the CST project
Set project = CreateObject("CSTStudio.Application")
' Path to save the exported images
exportPath = "C:\Path\To\Export\Directory\" ' Change this to your desired path
' Initialize the base values from your parameter list
SL = 59
SW = 76
SH = 1.5
Mt = 0.035
PL = 29.5
PW = 38
ML = 14.75 ' This is typically calculated as SL/2 - PL/2
MW = 2.86
InL = 9
InW = 0.74
k = 5.62
' Reset before each execution of this script
Call StoreParameter("PL", PL)
Call StoreParameter("PW", PW)
' Loop to generate images for different sizes
For scalingFactor = 0.30 To 0.6 Step 0.10
' Calculate new parameters only for the patch length and width
PL = 29.5 * scalingFactor
PW = 38 * scalingFactor
' Update CST with new parameters
Call StoreParameter("PL", PL)
Call StoreParameter("PW", PW)
' Rebuild and solve the project
Call Rebuild
Call RunSolver()
' Export the farfield plot
fileName = exportPath & "Antenna_Size_" & scalingFactor & ".png" ' Adjusted to export as .png
With FarfieldPlot
.Reset
.Plottype "3d"
.SetThetaStart 0
.SetThetaEnd 180
.SetPhiStart 0
.SetPhiEnd 360
.Step 1
.Step2 1
.SetPlotMode "directivity"
.SetScaleLinear True
.SetLogRange 40
.EnablePhaseCenterCalculation True
.SetPhaseCenterComponent "Theta"
.SetPhaseCenterPlane "both"
.SetPhaseCenterAngularLimit 30
Call SelectTreeItem("Farfields")
.Plot
.ASCIIExportAsSource fileName
End With
Next scalingFactor
' Notify completion
MsgBox "Generation of far-field images completed."
End Sub