Hallo all,
I'm trying to automate my design flow, so I decide to create a Python CST script that allows me to design a circular component and query some parameters. I try to use the VBA syntax with Python, and I managed to create some structures. Now I need to define the units, the background and the boundaries. I start with the units, but quickly saw that I can change the units with a macro in CST, but not through Python.... I don't even get an error message. Can someone give me an example python vba code on how to do it (If you have an code for the Background and Boundries it will be nice to post it too). Thanks a lot
CST Studio Suite
PS: Here is my code.
mport sys sys.path.append(r"/....../cst/2021/LinuxAMD64/python_cst_libraries/") import cst import cst.interface import cst.results import numpy as np # import scipy.stats import time import shutil
# Local path to CST project file --> Works cst_path = r'/....../CST Python/Test_Object/' # path cst_project = 'TestStruct' # CST project cst_project_path = cst_path + cst_project + '.cst' # Open CST as software mycst =cst.interface.DesignEnvironment() # Create Project in Project directory and name it obj =cst.interface.DesignEnvironment.open_project(mycst,cst_project_path)
its = 'Sub Main () ' \\
'\\nWith Units' + \\
'\\n.Geometry "m"' + \\
'\\n.TemperatureUnit "kelvin"' + \\
'\\n.Frequency "ghz"' + \\
'\\n.Time "ns"' + \\
'\\nEnd With' + \\
'\\nEnd Sub'
obj.schematic.execute_vba_code(Units, timeout=None)
# save project into Patbh
cst.interface.Project.save(obj, cst_project_path, False)
#Close CST
cst.interface.Project.close(obj)