:class:`Modeler` ================ .. py:class:: ansys.geometry.core.modeler.Modeler(host: str = DEFAULT_HOST, port: str | int = DEFAULT_PORT, channel: grpc.Channel | None = None, remote_instance: Optional[ansys.platform.instancemanagement.Instance] = None, docker_instance: Optional[ansys.geometry.core.connection.docker_instance.LocalDockerInstance] = None, product_instance: Optional[ansys.geometry.core.connection.product_instance.ProductInstance] = None, timeout: ansys.geometry.core.typing.Real = 120, logging_level: int = logging.INFO, logging_file: pathlib.Path | str | None = None, backend_type: ansys.geometry.core.connection.backend.BackendType | None = None) Provides for interacting with an open session of the Geometry service. :Parameters: **host** : :class:`python:str`, default: :obj:`DEFAULT_HOST` Host where the server is running. **port** : :obj:`Union`\[:class:`python:str`, :class:`python:int`], default: :obj:`DEFAULT_PORT` Port number where the server is running. **channel** : :obj:`~grpc.Channel`, default: :data:`python:None` gRPC channel for server communication. **remote_instance** : :obj:`ansys.platform.instancemanagement.Instance`, default: :data:`python:None` Corresponding remote instance when the Geometry service is launched using `PyPIM `_. This instance is deleted when the :func:`GrpcClient.close ` method is called. **docker_instance** : :obj:`LocalDockerInstance`, default: :data:`python:None` Corresponding local Docker instance when the Geometry service is launched using the :func:`launch_docker_modeler` method. This instance is deleted when the :func:`GrpcClient.close ` method is called. **product_instance** : :obj:`ProductInstance`, default: :data:`python: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 :func:`GrpcClient.close ` method is called. **timeout** : :obj:`Real`, default: 120 Time in seconds for trying to achieve the connection. **logging_level** : :class:`python:int`, default: :obj:`INFO` Logging level to apply to the client. **logging_file** : :class:`python:str`, :obj:`Path`, default: :data:`python:None` File to output the log to, if requested. .. !! processed by numpydoc !! .. py:currentmodule:: Modeler Overview -------- .. tab-set:: .. tab-item:: Methods .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~create_design` - Initialize a new design with the connected client. * - :py:attr:`~get_active_design` - Get the active design on the modeler object. * - :py:attr:`~read_existing_design` - Read the existing design on the service with the connected client. * - :py:attr:`~close` - Access the client's close method. * - :py:attr:`~exit` - Access the client's close method. * - :py:attr:`~open_file` - Open a file. * - :py:attr:`~run_discovery_script_file` - Run a Discovery script file. .. tab-item:: Properties .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~client` - ``Modeler`` instance client. * - :py:attr:`~designs` - All designs within the modeler workspace. * - :py:attr:`~repair_tools` - Access to repair tools. * - :py:attr:`~prepare_tools` - Access to prepare tools. * - :py:attr:`~measurement_tools` - Access to measurement tools. .. tab-item:: Special methods .. list-table:: :header-rows: 0 :widths: auto * - :py:attr:`~__repr__` - Represent the modeler as a string. Import detail ------------- .. code-block:: python from ansys.geometry.core.modeler import Modeler Property detail --------------- .. py:property:: client :type: ansys.geometry.core.connection.client.GrpcClient ``Modeler`` instance client. .. !! processed by numpydoc !! .. py:property:: designs :type: dict[str, ansys.geometry.core.designer.design.Design] All designs within the modeler workspace. .. rubric:: Notes This property is read-only. **DO NOT** modify the dictionary. .. !! processed by numpydoc !! .. py:property:: repair_tools :type: ansys.geometry.core.tools.repair_tools.RepairTools Access to repair tools. .. !! processed by numpydoc !! .. py:property:: prepare_tools :type: ansys.geometry.core.tools.prepare_tools.PrepareTools Access to prepare tools. .. !! processed by numpydoc !! .. py:property:: measurement_tools :type: ansys.geometry.core.tools.measurement_tools.MeasurementTools Access to measurement tools. .. !! processed by numpydoc !! Method detail ------------- .. py:method:: create_design(name: str) -> ansys.geometry.core.designer.design.Design Initialize a new design with the connected client. :Parameters: **name** : :class:`python:str` Name for the new design. :Returns: :obj:`Design` Design object created on the server. .. !! processed by numpydoc !! .. py:method:: 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_backend** : :ref:`bool `, default: :data:`python: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: :obj:`Design` Design object already existing on the modeler. .. !! processed by numpydoc !! .. py:method:: read_existing_design() -> ansys.geometry.core.designer.design.Design Read the existing design on the service with the connected client. :Returns: :obj:`Design` Design object already existing on the server. .. !! processed by numpydoc !! .. py:method:: close() -> None Access the client's close method. .. !! processed by numpydoc !! .. py:method:: exit() -> None Access the client's close method. .. rubric:: Notes This method is calling the same method as :func:`close() `. .. !! processed by numpydoc !! .. py:method:: open_file(file_path: str | pathlib.Path, 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_path** : :class:`python:str`, :obj:`~pathlib.Path` Path of the file to open. The extension of the file must be included. **upload_to_server** : :ref:`bool ` 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_options** : :obj:`ImportOptions` Import options that toggle certain features when opening a file. :Returns: :obj:`Design` Newly imported design. .. !! processed by numpydoc !! .. py:method:: __repr__() -> str Represent the modeler as a string. .. !! processed by numpydoc !! .. py:method:: run_discovery_script_file(file_path: str | pathlib.Path, script_args: dict[str, str] | None = None, import_design: bool = False, api_version: int | str | ansys.geometry.core.connection.backend.ApiVersions = None) -> tuple[dict[str, str], 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_path** : :class:`python:str` | :obj:`~pathlib.Path` Path of the file. The extension of the file must be included. **script_args** : :class:`python:dict`\[:class:`python:str`, :class:`python:str`], optional. Arguments to pass to the script. By default, ``None``. **import_design** : :ref:`bool `, 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``. **api_version** : :class:`python:int` | :class:`python:str` | :obj:`ApiVersions`, :obj:`optional` The scripting API version to use. For example, version 23.2 can be passed as an integer 232, a string "232" or using the ``ansys.geometry.core.connection.backend.ApiVersions`` enum class. By default, ``None``. When specified, the service will attempt to run the script with the specified API version. If the API version is not supported, the service will raise an error. If you are using Discovery or SpaceClaim, the product will determine the API version to use, so there is no need to specify this parameter. :Returns: :class:`python:dict`\[:class:`python:str`, :class:`python:str`] Values returned from the script. :obj:`Design`, :obj:`optional` Up-to-date current design. This is only returned if ``import_design=True``. :Raises: :obj:`GeometryRuntimeError` If the Discovery script fails to run. Otherwise, assume that the script ran successfully. .. rubric:: Notes The Ansys Geometry Service only supports scripts that are of the same version as the running service. Any ``api_version`` input will be ignored. .. !! processed by numpydoc !!