Becoming Acquainted with gRPC
To use Sherlock’s APIs, you will need programming experience (gRPC supports over a dozen computer languages) and a familiarity with gRPC as well. If you are new to gRPC, the official website provides a wealth of information to get you started: an overview of gRPC, a quick-start option, tutorials, downloads, and complete instructions for each supported computer language. If you want to begin with an overview of basic concepts, visit the Introduction to gRPC page. If you would rather dive in quickly and learn by doing, visit their Supported Languages and Platform page and click the programming language you prefer. This directs you to a quick-start guide and tutorials tailored for that language. As of this printing, gRPC supports the following languages: Android Java, C#/.NET, C++, Dart, Go, Java, Kotlin”/JVM, Node, Objective-C, PHP, Python, Ruby, and Web.Where to Find the Sherlock .proto Files
All the Sherlock.proto files you need to run the APIs were placed on your
hard drive when you installed the Ansys software (version 211 and later). You
will find the files in the following location (the file path may vary if you
installed your Ansys software in a nondefault location):
Windows: C:/Program Files/ANSYS Inc/v251/sherlock/grpc
Linux: /ansys_inc/v251/sherlock/grpc
The instructions from the gRPC website explain how to implement the .proto
files. Currently, the .proto files included with Sherlock are:
- SherlockAnalysisService.proto
- SherlockCommonService.proto
- SherlockLayerService.proto
- SherlockLifeCycleService.proto
- SherlockModelServices.proto
- SherlockPartsService.proto
- SherlockProjectService.proto
- SherlockStackupService.proto
Connecting to the Sherlock gRPC Server
To use Sherlock’s API’s, you must connect to the gRPC server. To connect, do the following: For Windows users, open your computer’s command-line interface and enter the command below (you can copy and paste the text) and press Enter. This will change the active directory to the location of your Sherlock installation. If you installed your Ansys software in a non-default location, modify the command-line accordingly.
Running API’s without the Sherlock User Interface
Sherlock allows you to run API’s without launching the Sherlock user interface. With this option enabled, Sherlock displays no splash screens, progress dialogs, nor console output. Only error dialogs are displayed. This option can be helpful if you wish, for example, to run a batch of analyses quickly. To suppress Sherlock’s user interface, simply add-noGUI to the command
line when launching Sherlock as described earlier in the previous section. For example:
Windows:
AppData/Roaming/Sherlock/logs (Windows) or the
.sherlock/logs folder of the home directory (Linux). To exit Sherlock, use
the ExitRequest API.
Pre-Generated Python Scripts
Starting with Sherlock 22.2, Python client-side scripts have been generated and included with the Sherlock installation. To begin using the scripts, do the following:-
Verify the following software is installed on your computer:
Python: Ansys recommends Python version 3.6 or later. If you need to upgrade, download the latest version from python.org/downloads and install according to the instructions on the website.
grpcio and grpcio-tools (versions 1.39.0 or later) and protobuf (3.17.3 or later). Install them using the pip command in Python. In the Windows command prompt, enter the following:
If you have them installed already, you can upgrade grpcio-tools and its dependencies using the following command in Python:
-
In Windows Environment Variables, add the file path to the Python scripts to the Path System variable. If your Ansys software is installed in the default location, the path to the scripts looks like this:
C:\Program Files\ANSYS Inc\v251\sherlock\grpc\python
Installing and Setting Up BloomRPC (Optional)
The BloomRPC application is an open source GUI client. It is not required for running Sherlock’s APIs, but it does provide a simple way for you to enter an API request and see the response. (See the screenshot below.) This link will take you to the GitHub website where you can download the latest setup file. Once you have installed BloomRPC, follow the configuration instructions below.
- Open the BloomRPC application.
-
Load the
.protofiles into BloomRPC by clicking on the icon in the Protos panel. This will open a file explorer interface. Navigate to your Sherlock installation and select all the Sherlock
.protofiles. (See the section above Where to Find the Sherlock .proto Files.) - When successfully loaded into BloomRPC, the files will appear in the Protos panel (see A in image below).
- Connect to the server by entering the server address. In the example below (B), 0.0.0.0:9090 is shown, but use whatever port number you chose in the section above, Connecting to the Sherlock gRPC Server.
