NativeApi#

class ansys.systemcoupling.core.native_api.NativeApi(rpc_impl)#

Exposes the native System Coupling command and query API into PySystemCoupling.

This class allows commands and queries to be scripted similarly to how it is done in System Coupling’s own command-line interface (CLI). The main difference is that rather than being exposed into the global Python environment, here commands and queries are made available as attributes of this class.

The path-based syntax of the native API is also supported. However, instead of using the global DatamodelRoot() query as the path root, use the instance of this class as the root. (Note that while DatamodelRoot can be called here, it returns the string value of the root path, so it cannot be used in the same way as in the System Coupling CLI.)

__getattr__(name)#

Provides access to the native System Coupling commands and queries API as attributes of this class’s instance.

For example, the System Coupling Solve() command can be invoked on an instance of the syc class as follows:

syc.Solve()

Note

This is equivalent to using the execute_command method like this:

syc.execute_command('Solve')

This method also supports a convenient data model access syntax, which is very close to that available in the native CLI.

For example, if System Coupling exposes a data model object SolutionControl, then various operations are supported, as shown below.

Query state of object:

state = syc.SolutionControl.GetState()

Note that this is an alternative to:

state = syc.execute_command('GetState',
                            ObjectPath='/SystemCoupling/SolutionControl')

Query value of object property:

option = syc.SolutionControl.DurationOption

Set multiple object object properties:

syc.SolutionControl = {
    'DurationOption': 'NumberOfSteps',
    'NumberofSteps': 5
}

Set single property:

syc.SolutionControl.NumberOfSteps = 6

In general, full “path” access to the data model is supported, including named object syntax familiar from the native CLI:

syc.CouplingInterface['intf1'].DataTransfer['temp']...
Parameters:
name

Name of the attribute being accessed.

execute_command(name, **kwargs)#

Execute the named command or query and return the result.

All commands and queries take one or more keyword arguments. Some of these arguments can be optional, depending on the command or query.

A query returns a value of a type that is dependent on the query.

A few commands return a value (again with a type dependent on the command), but most return None.

Note that the __getattr__-based exposure of the API provides a more convenient syntax.

Parameters:
name

Name of the command (or query) to execute.

kwargs

Keyword arguments to the command.