Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Making CST Files with Matlab

Status
Not open for further replies.

Firewall

Newbie level 3
Joined
May 4, 2013
Messages
3
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,283
Activity points
1,320
I'm trying to make a CST model from within matlab. Here's the code I have so far:

Code:
cst = actxserver('CSTStudio.application');
mws = cst.invoke('NewMWS');
brick=invoke(mws,'Brick');
invoke(brick, 'Reset');
invoke(brick, 'Name', 'brick1');
invoke(brick, 'Component','component1');
invoke(brick, 'Material', 'PEC');
invoke(brick, 'Xrange', '0', '2');
invoke(brick, 'Yrange', '0', '3');
invoke(brick, 'Zrange', '0', '5');
invoke(brick, 'Create');
release(brick);
mws.invoke('saveas','TEST.cst','false');

so far so good; it makes the CST file. However, something weird happens: it made the model, the metal box is there, but it didn't update the history list (it's blank). So, if I either update the history list or run a matlab command like
Code:
mws.invoke('rebuild')
the box disappears.

Anyone knows why the history list isn't getting updated when using this interface?
 

@Firewall,

I'm considering pursuing a similar path with constructing my models in CST (through MATLAB). However I'm wondering if there are any documentation from CST or any other party that gives you a good idea about the process. I recall reading a thesis online once, where a student manipulates many of CST's methods using MATLAB but I can't seem to find it again.

Do you (or anyone reading this) have any material that might prove helpful ?

Bannay
 

I guess the short answer is no, I didn't really find anything useful, besides the CST documentation for VBA objects.

Most of what I figured out was from trial and error, and using the CST help files. This is basically what I think the process is:

1. With CST, you can make macros with VBA (some programming language that I'm not too familiar with).
2. Since CST is VBA-compatible, it can be accessed from other VBA-compatible programs (excel is a common example).
3. Matlab can also handle VBA-like commands, so you can use it to control CST.

CST's help files have a entire section about VBA 'objects' available for manipulation. (They also have a section specifically about using Matlab with CST, but that section only talks about getting results from CST, not making models for CST)
The CST help files give a detailed description of all the objects and their various settings. For example, if you look up the documentation for the 'Brick' object, it gives a list of a bunch of methods used to modify a brick. At the bottom, it gives an example of how to create a 'brick' object in VBA:
Code:
With Brick
    .Reset
    .Name ("brick1")
    .Component ("component1")
    .Material ("PEC")
    .Xrange (0, 2)
    .Yrange (0, 3)
    .Zrange (0, "a+3")
    .Create
End With

compare that to the matlab brick commands I have in my original post, and that's basically I've been making CST files with matlab: I found the relevant VBA documentation in CST, and translated the CST-VBA into matlab-VBA. I found out how to do the matlab-VBA commands online and from older posts in this forum.

I've attached two files: one is the VBA code used to create a template for a planar filter (mm, GHz, ns, electric boundaries, etc). I grabbed it from the history list of a CST file that used the template.
The second file is the matlab version of the template. the 'mws' variable/object in this script is the same as the one in the original post:
Code:
cst = actxserver('CSTStudio.application');
mws = cst.invoke('NewMWS');

From comparing the two, you pretty easily see how to map VBA commands to matlab; most of the objects in the file (Units, Background, Boundary, Mesh, Solver) have documentation in the CST help files. You can also see how amazingly tedious it is to build files with all the correct simulation settings.

So that's all I have to offer. I've still having the problems mentioned in the original post, though, and would gladly accept any new information anybody has to share.
 

Attachments

  • filter.txt
    1.8 KB · Views: 210
  • filtertemplate.m.txt
    2.2 KB · Views: 255
I have now fought CST for long, and I also encountered this issue of a history-less brick creation. I found a work-around; although it is not pretty, the function AddToHistory does the job. You must create the component "MyBeautifulBrick" before this creation.

Code:
 mws.invoke('AddToHistory', 'BricksyCreation',[...
    sprintf('With Brick\n') ...
    sprintf('  .Reset\n') ...
    sprintf('  .Name "Bricksy"\n') ...
    sprintf('  .Component "MyBeautifulBrick"\n') ... 
    sprintf('  .Material "PEC"\n') ...
    sprintf('  .Xrange "%0.6f", "%0.6f"\n', -w/2, w/2) ...
    sprintf('  .Yrange "%0.6f", "%0.6f"\n', -h/2, h/2) ...
    sprintf('  .Zrange "%0.6f", "%0.6f"\n', -d/2, d/2) ...
    sprintf(' .Create\n') ...
    sprintf('End With')])
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top