![Page 1: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/1.jpg)
www.cst.com | Oct-071
CST STUDIO SUITE™
Introduction in VBA
Macro usage and programming
M. Balk
Existing Macros
Different Macro Types
Templates
Structure of a Macro
Example
![Page 2: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/2.jpg)
www.cst.com | Oct-072
Outline
�Why macro programming?
�Existing macros
�Different types of macros
�Creating and testing new macros
�Getting more information
![Page 3: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/3.jpg)
www.cst.com | Oct-073
Outline
�Why macro programming?
�Existing macros
�Different types of macros
�Creating and testing new macros
�Getting more information
![Page 4: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/4.jpg)
www.cst.com | Oct-074
Why Macro Programming?
� Automate common tasks, save time, increase productivity
� Extend the program‘s capabilities, e.g. post processing, optimization
� Customize the program for particular applications
� Make advanced functionality available to less experienced users
CST STUDIO SUITE‘s macro language:
� Compatible to the widely used VBA (Visual Basic for Applications)� COM based
� CST STUDIO SUITE can be controlled by other applications� CST STUDIO SUITE can control other applications
![Page 5: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/5.jpg)
www.cst.com | Oct-075
Integration Into Workflow
CST Studios can be both: OLE client and server
MS WindowsScripting
Host
Excel, Word,Matlab, AutoCad,
etc...
CST Software(MWS, DS)
e.g. bidirectional Excel link
COMDCOM
reports
e.g. ppt-Reports
OLE: CommunicationStandard for Data Exchange
![Page 6: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/6.jpg)
www.cst.com | Oct-076
Integration Into Workflow
! "C:\Program Files\CST STUDIO SUITE 2006B\CST DESIGN ENVIRONMENT.exe" –m D:\MBK\Start_CST_5.bas
MatlabCST Software(CST MWS,
CST DS)
Call via command line option
Call:
Execute command in Matlab CST MWS is calledwithin theCST DESIGN ENVIRONMENT
Path of the VBA script
Sub MainOpenFile("D:\MBK\test1\test1.mod")Solver.StartSave
End Sub
Opens an existing CST MWS file
Start of Transient Solver
Saves results and gives control back to Matlab
![Page 7: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/7.jpg)
www.cst.com | Oct-077
Project Templates
File -> New...
File -> Select Template...or later:
At the beginning:
Customize the default settings for particular types of app lications.
The template library can be easily extended
![Page 8: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/8.jpg)
www.cst.com | Oct-079
� Input some commands you often use for your MWS structures, e.g.:
� Frequency range, units, Background-mat + boundaries
� Definition of materials (parameters, favorite colours ...)
� Working plane settings (especially snapping !)
� Monitors at favorite frequencies, ...
� Open the history list
� Mark the commands, press „Macro“
� Give a name to your macro, e.g. „File / My defaults“
� Click „Make globally available“, then „OK“
Project Templates
![Page 9: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/9.jpg)
www.cst.com | Oct-0710
Postprocessing
� Import and compare with measured data
� Special postprocessing (e.g. TDR)
� Store Views and Animations in different formats
� Userdefined goal-functions (e.g. antenna goal)
� Creating a Powerpoint Presentation
Customize CST MWS
exactly to your needs
![Page 10: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/10.jpg)
www.cst.com | Oct-0711
Outline
�Why macro programming?
�Existing macros
�Different types of macros
�Creating and testing new macros
�Getting more information
![Page 11: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/11.jpg)
www.cst.com | Oct-0712
Useful, predefined macros
![Page 12: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/12.jpg)
www.cst.com | Oct-0713
Useful, predefined macros
![Page 13: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/13.jpg)
www.cst.com | Oct-0714
Useful, predefined macros
![Page 14: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/14.jpg)
www.cst.com | Oct-0715
Useful, predefined macros
![Page 15: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/15.jpg)
www.cst.com | Oct-0716
Outline
�Why macro programming?
�Existing macros
�Different types of macros
�Creating and testing new macros
�Getting more information
![Page 16: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/16.jpg)
www.cst.com | Oct-0717
Structure Macros and Control Macros
Structure macros
� Modify the structure
� Stored in the history list for parametric model definition
� Name: ... . mcs
� Example: Creation of advanced geometry, e.g. spirals,…c
Macros -> Construct -> Coils -> Sectioned Spiral
![Page 17: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/17.jpg)
www.cst.com | Oct-0718
Control macros
� Do not modify the structure
� Do not need to be stored in the history list
� Name: ... . mcr
� Examples: Postprocessing, Calculation of analytical line
impedance, etc.
Structure Macros and Control Macros
Macros -> Calculate -> Calculate Analytical Line
Impedance
![Page 18: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/18.jpg)
www.cst.com | Oct-0719
Project macros
� Can be either command macros or structure macros
� Specific for a particular project
� Stored with the project.
� Not available for other projects as well
Global macros
� Can be either command macros or structure macros
� Generally useful
� Stored in a global location (Global Macro Path)
� Can be shared accross projects
Project Macros and Global Macros
![Page 19: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/19.jpg)
www.cst.com | Oct-0720
Result Templates
Performs an action
� Purpose: Customized and automized postprocessing
� Store in <installationpath>/Library/Result Templates/my_template.rtp
�Will be evaluated after each solver run.
� Can perform just an action or return 1D or 0D values.
![Page 20: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/20.jpg)
www.cst.com | Oct-0721
Result Templates
Returns a value
� Purpose: Customized and automized postprocessing
� Store in <installationpath>/Library/Result Templates/my_template.rtp
�Will be evaluated after each solver run.
� Can perform just an action or return 1D or 0D values.
![Page 21: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/21.jpg)
www.cst.com | Oct-0722
Outline
�Why macro programming?
�Existing macros
�Different types of macros
�Creating and testing new macros
�Getting more information
![Page 22: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/22.jpg)
www.cst.com | Oct-0723
The Integrated Development Environment
Open IDE
![Page 23: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/23.jpg)
www.cst.com | Oct-0724
Edit macro code here (syntax highlighting)
Run the macro Debug the macro
The Integrated Development Environment
![Page 24: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/24.jpg)
www.cst.com | Oct-0725
The Integrated Development Environment
Macro Debugger:
� Set breakpoints� Step through the macro� Watch variables� etc…
![Page 25: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/25.jpg)
www.cst.com | Oct-0726
The Integrated Development Environment
Graphical GUI builder
Source code for the dialog box is automatically created andInserted at the caret‘s position
![Page 26: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/26.jpg)
www.cst.com | Oct-0727
There exist different ways to create a macro
� Copy and modify an existing macro
� Go to the history list, select lines and press „Macro“
� Use Macro -> Make VBA Control Macro and start from Scratch
� Let MWS create the macro‘s framework by pressing „Edit“ for
� User defined excitation function
� User defined parameter sweep watch
� User defined optimizer goal function
How to Create Macros?
![Page 27: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/27.jpg)
www.cst.com | Oct-0728
Outline
�Why macro programming?
�Existing macros
�Different types of macros
�Creating and testing new macros
�Getting more information
![Page 28: CST STUDIO SUITE™ Introductionin VBA Macrousageand programming · PDF fileIntroductionin VBA Macrousageand programming M. Balk ExistingMacros Different MacroTypes Templates Structureof](https://reader036.vdocuments.net/reader036/viewer/2022082203/5aa49e667f8b9ab4788c1f0c/html5/thumbnails/28.jpg)
www.cst.com | Oct-0729
� Advanced Topics Manual
� Check the VBA online manual
(Help -> VBA Macro Language)
� Have a look at the pre-loaded
macro examples
� Visit a special training class on macro
programming
� Learning by doing….
Getting More Information