The var_value_convert.py module#

Summary#

ToGRPCVisitor

Produces a gRPC VariableValue message for a given

ValueTypeNotSupportedError

Raised if an attempt is made to convert a value with a known but

interop_type_to_mc_type_string

Given an atvi.VariableType, create the corresponding ModelCenter

mc_type_string_to_interop_type

Given a ModelCenter type string, create the corresponding

grpc_type_enum_to_interop_type

Given a value of VariableType, return the appropriate value of

interop_type_to_grpc_type_enum

Given a value of atvi.VaribleType, return the appropriate value of

convert_grpc_value_to_atvi

Produce an atvi.IVariableValue object from a gRPC message.

convert_interop_value_to_grpc

Create an equivalent VariableValue message from a

Description#

Defines methods for converting between a gRPC message and an IVariableValue.

For more information, see IVariableValue in the PyAnsys Tools Variable Interop documentation.

Module detail#

var_value_convert.interop_type_to_mc_type_string(original: ansys.tools.variableinterop.VariableType) str#

Given an atvi.VariableType, create the corresponding ModelCenter type string.

var_value_convert.mc_type_string_to_interop_type(original: str) ansys.tools.variableinterop.VariableType#

Given a ModelCenter type string, create the corresponding atvi.VariableType.

var_value_convert.grpc_type_enum_to_interop_type(original: ansys.api.modelcenter.v0.variable_value_messages_pb2.VariableType) ansys.tools.variableinterop.VariableType#

Given a value of VariableType, return the appropriate value of atvi.VariableType.

var_value_convert.interop_type_to_grpc_type_enum(original: ansys.tools.variableinterop.VariableType) ansys.api.modelcenter.v0.variable_value_messages_pb2.VariableType#

Given a value of atvi.VaribleType, return the appropriate value of VariableType.

Note

This method does not handle reference types as they map to atvi.VariableType.UNKNOWN and are thus indistinguishable from actual unknown types.

var_value_convert.convert_grpc_value_to_atvi(original: ansys.api.modelcenter.v0.variable_value_messages_pb2.VariableValue, engine_is_local: bool = True) ansys.tools.variableinterop.IVariableValue#

Produce an atvi.IVariableValue object from a gRPC message.

Parameters:
originalVariableValue

Original gRPC message.

engine_is_localbool

Whether the engine that created the file is running on the local machine. The default is True. If False, the engine is running on a remote machine

Returns:
Converted value.
var_value_convert.convert_interop_value_to_grpc(original: ansys.tools.variableinterop.IVariableValue, local_file_context_stack: contextlib.ExitStack | None = None, engine_is_local=False) ansys.api.modelcenter.v0.variable_value_messages_pb2.VariableValue#

Create an equivalent VariableValue message from a atvi.IVariableValue object.