cst.interface package

Module Contents

The cst.interface package provides a python interface that allows to control the CST Studio Suite. It is possible to connect to a running DesignEnvironnent (main screen) or start a new one. Once connected the package provides access to CST projects (.cst) which can be opened, closed and saved and provide access to the associated applications (prj.modeler).

class cst.interface.DesignEnvironment(mode=StartMode.New, pid=-1)

This class provides an interface to the CST Studio Suite main frontend. It allows to connect to, and open new CST Studio Suite instances. Furthermore it allows to open or create .cst projects.

active_project(self: _cst_interface.DesignEnvironment) → object

Get the currently active project.

close(self: _cst_interface.DesignEnvironment) → None

Closes the DesignEnvironment.

connect(pid: int) → object

Connects to an existing DE with given PID.

connect_to_any() → object

Connects to any existing DE, if multiple DEs are open the connection will be built-up to a random open DE. If you want to connect to a specific DE, use the connect() method.

connect_to_any_or_new() → object

Connects to any existing DE or opens a new one if none are open.

get_open_project(self: _cst_interface.DesignEnvironment, path: str) → object

Returns a handle to an already open project with the path given by path. Raises an exception when there is no project found corresponding to the given path.

get_open_projects(self: _cst_interface.DesignEnvironment, re_filter: str='.*') → list

Returns a list of currently open projects matching the regular expression filter re_filter.

has_active_project(self: _cst_interface.DesignEnvironment) → bool

Queries whether the DesignEnvironment has an active project.

in_quiet_mode(self: _cst_interface.DesignEnvironment) → bool

Queries whether message boxes are currently suppressed. Please note: Dialog boxes which require user input cannot be suppressed.

is_connected(self: _cst_interface.DesignEnvironment) → bool

Returns whether this object is still connected to a live DE.

list_open_projects(self: _cst_interface.DesignEnvironment) → List[str]

Returns the paths of the currently open projects.

new(options: List[str]=[]) → object

Opens a new DE and connects to it. A number of command line options may be passed as a list of strings. For a list of available options call print_command_line_options()

new_cs(self: _cst_interface.DesignEnvironment) → object

Creates a new CST Cable Studio project and returns an instance of Project pertaining to it.

new_ds(self: _cst_interface.DesignEnvironment) → object

Creates a new CST Design Studio project and returns an instance of Project pertaining to it.

new_ems(self: _cst_interface.DesignEnvironment) → object

Creates a new CST EM Studio project and returns an instance of Project pertaining to it.

new_mps(self: _cst_interface.DesignEnvironment) → object

Creates a new CST Mphysics Studio project and returns an instance of Project pertaining to it.

new_mws(self: _cst_interface.DesignEnvironment) → object

Creates a new CST Microwave Studio project and returns an instance of Project pertaining to it.

new_pcbs(self: _cst_interface.DesignEnvironment) → object

Creates a new CST PCB Studio project and returns an instance of Project pertaining to it.

new_project(self: _cst_interface.DesignEnvironment, project_type: _cst_interface.ProjectType) → object

Opens a new project of given project_type and returns an instance of Project pertaining to it.

new_ps(self: _cst_interface.DesignEnvironment) → object

Creates a new CST Particle Studio project and returns an instance of Project pertaining to it.

open_project(self: _cst_interface.DesignEnvironment, path: str) → object

Opens the project given by path in a new tab and returns an instance of Project pertaining to it.

pid(self: _cst_interface.DesignEnvironment) → int

Return the Process ID (PID) to which this DesignEnvironment is connected.

print_command_line_options() → None

Prints the available command line options which can be used with new().

print_version() → None

Prints the version string of the current DE.

set_quiet_mode(self: _cst_interface.DesignEnvironment, flag: bool) → None

When flag is set to True message boxes are suppressed. Please note: Dialog boxes which require user input cannot be suppressed.

version() → str

Return the version string of the current DE.

class cst.interface.Project

Provides an interface to live CST projects. Offers capabilities to save and close projects, but also carries the associated interfaces to various applications.

activate(self: _cst_interface.Project) → None

Makes this project the currently active project.

close(self: _cst_interface.Project) → None

Closes the project without saving.

filename(self: _cst_interface.Project) → str

Returns the current filename of the project.

modeler

Gives access to the modeler (Modeler) associated with the project if it exists. Is None when there is no associated modeler.

project_type(self: _cst_interface.Project) → NProjectsEmbeddedBase::eProjects

Returns the project type of this project.

save(self: _cst_interface.Project, path: str='', include_results: bool=False) → None

Saves the project to the specified path and optionally includes the results. If no path is given (default) then the current filename will be used.

schematic

Gives access to the schematic (Schematic) associated with the project if it exists. Is None when there is no associated schematic.

class cst.interface.Modeler

This class provides an interface to the 3D modeler

add_to_history(header: str, vba_code: str, timeout=None) → bool

AddToHistory creates a new history block in the modeler with the given header-name and executes the vba_code

full_history_rebuild(timeout=None) → object

Trigger a full rebuild of the modeler history.

get_active_solver_name(timeout=None) → str

Returns the currently active solver name.

run_solver(timeout=None) → bool

Runs the currently selected solver until it finishes and returns whether the solver run was successful.

class cst.interface.Schematic

This class provides an interface to the schematic

execute_vba_code(vba_code: str, timeout=None) → bool

Executes VBA Code Snippet