微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微波和射频技术 > 电磁仿真讨论 > Extracting information from a CST project file and saving it in an Excel format

Extracting information from a CST project file and saving it in an Excel format

时间:03-30 整理:3721RD 点击:
I have this routine I did for extracting information from a CST project file and save it in an EXCEL workbook.
Most of it works from the EXCEL VBA Editor.

I was not able to get to work a number of things and I have a few questions:

1. Option 3 below : if the project file is already open, how do I get the path and the project file name (through VBA commands)
2. CST does not disappear when VBA executes this command: Set studio = Nothing
3. Are there any examples of how to get the fields/currents through VBA commands?

Thanks

Kato


Public Sub Save_CST_Results()
pname = Sheet1.Cells(5, 2).Value 'read the directory (path) of the project file from excel cell
fln = Sheet1.Cells(6, 2).Value 'read the project file name from excel cell

ifln = pname + "\" + fln

Dim studio As Object

Set studio = CreateObject("CSTStudio.Application") 'Starts CST MICROWAVE STUDIO?

Dim proj As Object

'Set proj = studio.NewMWS ' Option 1 - starts a new project
Set proj = studio.OpenFile(ifln) ' Option 2 - opens an existing project file
' ? ' Option 3 - referes to an already open project file

Dim brick As Object ' Example of building a box
Set brick = proj.brick
brick.Reset
brick.Name "BrickOne"
brick.Xrange "0", "1"
brick.Yrange "0", "2"
brick.Zrange "0", "4"
brick.Create

Dim lib_ProjectDir As Object '
Set lib_ProjectDir = studio.GetProjectPath("Root") ' Extracts the path of the project file from an open project file
Shell "explorer " & ChrS(34) + lib_ProjectDir + ChrS(34), 1 ' DOES NOT WORK
Dim a11 As Object
Dim p11 As Object
Set a11 = proj.Result1D("a1(1)1(1)")
Set p11 = proj.Result1D("p1(1)1(1)")
Dim n As Integer
Dim frq As Double

n = a11.getN ' gets the number of points
For i = 1 To n
phase = Pi / 180# * p11.GetY(i - 1) ' gets the phase of S11
ampli = a11.GetY(i - 1) ' gets the amplitude of S11
freq = a11.getX(i - 1) ' gets the frequency vector
Sheet2.Cells(i + 1, 3).Value = freq
Sheet2.Cells(i + 1, 4).Value = ampli
Sheet2.Cells(i + 1, 5).Value = phase
Next i

proj.Quit ' close project file
Set studio = Nothing ' unload CST - DOES NOT WORK (CST is still there)End Sub

maybe you have to move it to a different forum !

Why? This is surely the most suitable forum for asking about CST.

thank you DeborahHarry,

Basically what I want to do is using macros (that one ussually uses inside the CST VBA editor) in the VBA editor in EXCEL. I did that for HFSS and it works great. EXCEL has the sheets and one can summarize a run in detail, so when you go back a month later you know everything you did (what paramater u used, how much CPU was used, how many iteration were necessary to converge, what convergence error etc). It's "just" a question of the object properties and methods of the CreateObject(CST.application) object. Could not find the full information about these.

上一篇:mesure distance in cst
下一篇:最后一页

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top