### Verify installation Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/getting-started/installing/development.rst Launch a Workbench server session to confirm the installation is working correctly. ```python from ansys.workbench.core import launch_workbench workbench = launch_workbench() ``` -------------------------------- ### Install in editable mode Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/getting-started/installing/development.rst Install the package such that source code changes are immediately reflected. ```bash python -m pip install --editable . ``` -------------------------------- ### Install PyWorkbench artifacts Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/getting-started/installing/windows.rst Install downloaded wheel or source distribution files using pip. ```text python -m pip install {{ wheels }} ``` ```text python -m pip install {{ source }} ``` -------------------------------- ### Start PyFluent Service and Connect Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Starts a Fluent system in Workbench, initiates the PyFluent service, and establishes a PyFluent client connection. Requires the 'ansys.fluent.core' library. ```python import ansys.fluent.core as pyfluent sys_name = wb.run_script_string( r"""import json wb_script_result=json.dumps(GetTemplate(TemplateName="FLUENT").CreateSystem().Name) """ ) server_info_file = wb.start_fluent_server(system_name=sys_name) fluent = pyfluent.connect_to_fluent(server_info_file_name=server_info_file) ``` -------------------------------- ### Install PyWorkbench development version Source: https://github.com/ansys/pyworkbench/blob/main/README.rst Use these commands to clone the repository and install the package in editable mode for development. ```bash git clone https://github.com/ansys/pyworkbench cd pyworkbench pip install -e . ``` -------------------------------- ### Start PySherlock Service and Connect Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Starts a Sherlock system in Workbench, initiates the PySherlock service, and establishes a PySherlock client connection. Requires the 'ansys.sherlock.core' library. ```python from ansys.sherlock.core import launcher as pysherlock sys_name = wb.run_script_string( r"""import json wb_script_result=json.dumps(GetTemplate(TemplateName="SherlockPre").CreateSystem().Name) """ ) server_port = wb.start_sherlock_server(system_name=sys_name) sherlock = pysherlock.connect_grpc_channel(port=server_port) ``` -------------------------------- ### Run Script File with Logging Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Execute a script file on the Workbench server with a specified logging level. This example sets the log level to 'info'. ```python wb.run_script_file("a_script_file_name", log_level="info") ``` -------------------------------- ### Verify PyWorkbench installation Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/getting-started/installing/windows.rst Launch the Workbench application to confirm that the package is correctly installed and configured. ```python from ansys.workbench.core import launch_workbench launch_workbench() ``` -------------------------------- ### Install PyWorkbench via PyPI Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/getting-started/installing/windows.rst Use the standard pip command to install the core PyWorkbench package from the Python Package Index. ```shell python -m pip install ansys-workbench-core ``` -------------------------------- ### Start PyMechanical Service and Connect Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Starts a Mechanical system, then initiates the PyMechanical service for that system and establishes a PyMechanical client connection. Requires the 'ansys.mechanical.core' library. ```python from ansys.mechanical.core import connect_to_mechanical sys_name = wb.run_script_string( r"""import json wb_script_result=json.dumps(GetTemplate(TemplateName="Static Structural (ANSYS)").CreateSystem().Name) """ ) server_port = wb.start_mechanical_server(system_name=sys_name) mechanical = connect_to_mechanical(ip="localhost", port=server_port) ``` -------------------------------- ### Upload File from Example Repository Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Uploads a data file directly from the Ansys example-data repository to the Workbench server. Specify the path relative to the 'pyworkbench' folder. ```python client.upload_file_from_example_repo("pymechanical-integration/agdb/two_pipes.agdb") ``` -------------------------------- ### Install PyWorkbench via pip Source: https://github.com/ansys/pyworkbench/blob/main/README.rst Use this command to install the stable version of the PyWorkbench library in user mode. ```bash pip install ansys-workbench-core ``` -------------------------------- ### Connect PyWorkbench to Local Ansys Workbench Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/getting-started/connection.rst Use this snippet to connect PyWorkbench to a local Ansys Workbench session. Ensure Ansys Workbench is running and the server has been started with `StartServer()`. ```python from ansys.workbench.core import connect_workbench workbench = connect_workbench(port=port) ``` -------------------------------- ### Launch Workbench Server with Options Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Launch a Workbench server with advanced options such as GUI mode, version, and custom working directories for server and client. ```python from ansys.workbench.core import launch_workbench wb = launch_workbench( show_gui=False, version="251", server_workdir="path_to_a_dir_on_server", client_workdir="path_to_a_dir_on_client", ) ``` -------------------------------- ### Create a virtual environment Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/getting-started/installing/development.rst Commands to create a clean Python virtual environment for different operating systems. ```text py -m venv ``` ```text python -m venv ``` -------------------------------- ### Launch Workbench Server Locally Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Launch a Workbench server on a local machine. This is useful for development and debugging. ```python from ansys.workbench.core import launch_workbench wb = launch_workbench() ``` -------------------------------- ### Connect to Workbench Server Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Connect to a running Workbench server using host and port. The client working directory can also be specified. ```python from ansys.workbench.core import connect_workbench host = "server_machine_name_or_IP" port = server_port_number wb = connect_workbench(host=host, port=port) ``` -------------------------------- ### Download All .out Files from Server Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Downloads all files with a '.out' extension from the server's working directory to the client. ```python wb.download_file("*.out") ``` -------------------------------- ### Activate the virtual environment Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/getting-started/installing/development.rst Commands to activate the virtual environment based on the operating system and shell. ```text \Scripts\activate.bat ``` ```text \Scripts\Activate.ps1 ``` ```text source /bin/activate ``` -------------------------------- ### Copy Mechanical Solver Output to Server Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Copies a Mechanical solver output file to the server's working directory. Requires the 'shutil' and 'os' modules. ```python wb.run_script_string( r"""import os import shutil work_dir = GetServerWorkingDirectory() mechanical_dir = mechanical.project_directory out_file_src = os.path.join(mechanical_dir, "solve.out") out_file_des = os.path.join(work_dir, "solve.out") shutil.copyfile(out_file_src, out_file_des) """ ) ``` -------------------------------- ### Launch Workbench Server Remotely Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Launch a Workbench server on a remote machine using provided credentials. Ensure valid user credentials are used. ```python from ansys.workbench.core import launch_workbench host = "server_machine_name_or_ip" username = "your_username_on_server_machine" password = "your_password_on_server_machine" wb = launch_workbench(host=host, username=username, password=password) ``` -------------------------------- ### Download Project Archive Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Saves the current Workbench project on the server, archives it, and downloads the archive to the client. The 'include_solution_result_files' argument controls whether solution results are included. ```python wb.download_project_archive( archive_name="my_project_archive", include_solution_result_files=False ) ``` -------------------------------- ### Upload Files to Workbench Server Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Upload specified files from the client to the server's working directory. Supports wildcards for file selection. ```python wb.upload_file("model?.prt", "*.agdb", "/path/to/some/file") ``` -------------------------------- ### Clone the repository Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/getting-started/installing/development.rst Use git to clone the PyWorkbench repository to your local machine. ```bash git clone git@github.com:ansys/pyworkbench ``` -------------------------------- ### Load Uploaded Geometry in Workbench Script Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Server-side script to load an uploaded geometry file from the server's working directory into a new Workbench system. ```python import os work_dir = GetServerWorkingDirectory() geometry_file = os.path.join(work_dir, "two_pipes.agdb") template = GetTemplate(TemplateName="Static Structural", Solver="ANSYS") system = CreateSystemFromTemplate(Template=template, Name="Static Structural (ANSYS)") system.GetContainer(ComponentName="Geometry").SetFile(FilePath=geometry_file) ``` -------------------------------- ### Run Workbench Script for Messages Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Run an IronPython script on the Workbench server to retrieve all message summaries. The result is assigned to wb_script_result as a JSON string. ```python import json messages = [m.Summary for m in GetMessages()] wb_script_result = json.dumps(messages) ``` -------------------------------- ### Connect PyWorkbench to Remote Ansys Workbench Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/getting-started/connection.rst Use this snippet to connect PyWorkbench to an Ansys Workbench session running on a remote machine. Provide the host name or IP address and the port number. ```python from ansys.workbench.core import connect_workbench workbench = connect_workbench(host=host_name_or_IP, port=port) ``` -------------------------------- ### Download File Without Progress Bar Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Downloads a specific file from the server to the client. The 'show_progress' argument can be set to False to disable the progress bar. ```python wb.download_file("solve.out", show_progress=False) ``` -------------------------------- ### Stop PyFluent Service Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Stops the PyFluent service for a specified Fluent system within Workbench. ```python wb.stop_fluent_server(system_name=sys_name) ``` -------------------------------- ### Stop PySherlock Service Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Stops the PySherlock service for a specified Sherlock system within Workbench. ```python wb.stop_sherlock_server(system_name=sys_name) ``` -------------------------------- ### Stop PyMechanical Service Source: https://github.com/ansys/pyworkbench/blob/main/doc/source/user-guide.rst Stops the PyMechanical service for a specified Mechanical system within Workbench. ```python wb.stop_mechanical_server(system_name=sys_name) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.