Modeler#

class ansys.geometry.core.modeler.Modeler(host: str = DEFAULT_HOST, port: beartype.typing.Union[str, int] = DEFAULT_PORT, channel: beartype.typing.Optional[grpc.Channel] = None, remote_instance: beartype.typing.Optional[ansys.platform.instancemanagement.Instance] = None, docker_instance: beartype.typing.Optional[ansys.geometry.core.connection.docker_instance.LocalDockerInstance] = None, product_instance: beartype.typing.Optional[ansys.geometry.core.connection.product_instance.ProductInstance] = None, timeout: beartype.typing.Optional[ansys.geometry.core.typing.Real] = 120, logging_level: beartype.typing.Optional[int] = logging.INFO, logging_file: beartype.typing.Optional[beartype.typing.Union[pathlib.Path, str]] = None, backend_type: beartype.typing.Optional[ansys.geometry.core.connection.backend.BackendType] = None)#

Provides for interacting with an open session of the Geometry service.

Parameters:
hoststr, default: DEFAULT_HOST

Host where the server is running.

portUnion[str, int], default: DEFAULT_PORT

Port number where the server is running.

channelChannel, default: None

gRPC channel for server communication.

remote_instanceansys.platform.instancemanagement.Instance, default: None

Corresponding remote instance when the Geometry service is launched using PyPIM. This instance is deleted when the GrpcClient.close method is called.

docker_instanceLocalDockerInstance, default: None

Corresponding local Docker instance when the Geometry service is launched using the launch_docker_modeler method. This instance is deleted when the GrpcClient.close method is called.

product_instanceProductInstance, default: None

Corresponding local product instance when the product (Discovery or SpaceClaim) is launched through the launch_modeler_with_geometry_service(), launch_modeler_with_discovery() or the launch_modeler_with_spaceclaim() interface. This instance will be deleted when the GrpcClient.close method is called.

timeoutReal, default: 120

Time in seconds for trying to achieve the connection.

logging_levelint, default: INFO

Logging level to apply to the client.

logging_filestr, Path, default: None

File to output the log to, if requested.

Overview#

create_design

Initialize a new design with the connected client.

get_active_design

Get the active design on the modeler object.

read_existing_design

Read the existing design on the service with the connected client.

close

Access the client’s close method.

open_file

Open a file.

run_discovery_script_file

Run a Discovery script file.

client

Modeler instance client.

repair_tools

Access to repair tools.

measurement_tools

Access to measurement tools.

__repr__

Represent the modeler as a string.

Import detail#

from ansys.geometry.core.modeler import Modeler

Property detail#

property Modeler.client: ansys.geometry.core.connection.client.GrpcClient#

Modeler instance client.

property Modeler.repair_tools: ansys.geometry.core.tools.repair_tools.RepairTools#

Access to repair tools.

property Modeler.measurement_tools: ansys.geometry.core.tools.measurement_tools.MeasurementTools#

Access to measurement tools.

Method detail#

Modeler.create_design(name: str) ansys.geometry.core.designer.design.Design#

Initialize a new design with the connected client.

Parameters:
namestr

Name for the new design.

Returns:
Design

Design object created on the server.

Modeler.get_active_design(sync_with_backend: bool = True) ansys.geometry.core.designer.design.Design#

Get the active design on the modeler object.

Parameters:
sync_with_backendbool, default: True

Whether to sync the active design with the remote service. If set to False, the active design may be out-of-sync with the remote service. This is useful when the active design is known to be up-to-date.

Returns:
Design

Design object already existing on the modeler.

Modeler.read_existing_design() ansys.geometry.core.designer.design.Design#

Read the existing design on the service with the connected client.

Returns:
Design

Design object already existing on the server.

Modeler.close() None#

Access the client’s close method.

Modeler.open_file(file_path: str, upload_to_server: bool = True, import_options: ansys.geometry.core.misc.options.ImportOptions = ImportOptions()) ansys.geometry.core.designer.design.Design#

Open a file.

This method imports a design into the service. On Windows, .scdocx and HOOPS Exchange formats are supported. On Linux, only the .scdocx format is supported.

If the file is a shattered assembly with external references, the whole containing folder will need to be uploaded. Ensure proper folder structure in order to prevent the uploading of unnecessary files.

Parameters:
file_pathstr

Path of the file to open. The extension of the file must be included.

upload_to_serverbool

True if the service is running on a remote machine. If service is running on the local machine, set to False, as there is no reason to upload the file.

import_optionsImportOptions

Import options that toggle certain features when opening a file.

Returns:
Design

Newly imported design.

Modeler.__repr__() str#

Represent the modeler as a string.

Modeler.run_discovery_script_file(file_path: str, script_args: beartype.typing.Optional[beartype.typing.Dict[str, str]] = None, import_design=False) beartype.typing.Tuple[beartype.typing.Dict[str, str], beartype.typing.Optional[ansys.geometry.core.designer.design.Design]]#

Run a Discovery script file.

Note

If arguments are passed to the script, they must be in the form of a dictionary. On the server side, the script will receive the arguments as a dictionary of strings, under the variable name argsDict. For example, if the script is called with the arguments run_discovery_script_file(..., script_args = {"length": "20"}, ...), the script will receive the dictionary argsDict with the key-value pair {"length": "20"}.

Note

If an output is expected from the script, it will be returned as a dictionary of strings. The keys and values of the dictionary are the variables and their values that the script returns. However, it is necessary that the script creates a dictionary called result with the variables and their values that are expected to be returned. For example, if the script is expected to return the number of bodies in the design, the script should create a dictionary called result with the key-value pair {"numBodies": numBodies}, where numBodies is the number of bodies in the design.

The implied API version of the script should match the API version of the running Geometry Service. DMS API versions 23.2.1 and later are supported. DMS is a Windows-based modeling service that has been containerized to ease distribution, execution, and remotability operations.

Parameters:
file_pathstr

Path of the file. The extension of the file must be included.

script_argsOptional[Dict[str, str]], optional.

Arguments to pass to the script. By default, None.

import_designbool, optional.

Whether to refresh the current design from the service. When the script is expected to modify the existing design, set this to True to retrieve up-to-date design data. When this is set to False (default) and the script modifies the current design, the design may be out-of-sync. By default, False.

Returns:
dict[str, str]

Values returned from the script.

Design, optional

Up-to-date current design. This is only returned if import_design=True.

Raises:
GeometryRuntimeError

If the Discovery script fails to run. Otherwise, assume that the script ran successfully.