Search Results

10 - Scripting

1.0 Introduction

In this tutorial, we will walk you through the setup process and provide an overview of how to run your first Python script for Dips.

Topics Covered in this Tutorial:

  • Python Environment
  • RocScript
  • Self-hosted Environment

Finished Product:

The finished product of this tutorial can be found in the Tutorial 10 Scripting.dips9 file, located in the Examples > Tutorials folder in your Dips installation folder.

2.0 Prerequisites

2.1 Dips Version 9

Before you begin, ensure you have the Dips program installed. You must have at minimum Version 9.001 in order to use this feature.

Legacy Dips versions do not support Python scripting.

2.2 Python Environment

There are two methods to run a script, which differ in the Python environment used:

  1. Running on RocScript Editor (for all levels of users):
  2. Running on your own Python environment (for advanced users):
    • Install the Dips Python API library.

Each method is detailed below.

3.0 Method 1: Using RocScript

3.1 Opening the RocScript Editor

In Dips:

  1. Select Scripting > Launch RocScript Editor Launch Rocscript from the ribbon.
  2. The RocScript Editor will launch in a separate application window.
You can also open the RocScript Editor from the Windows start menu.

3.2 Open a File

To open a file in the RocScript Editor:

  1. Select File > Open File option from the menu.
    Open a file in rocscript
  2. Select the Tutorial.py Python file from the tutorial folder directory located in the Examples > Tutorials folder in your Dips installation folder.

3.3 Run the File

To run the file:

  1. Click on the Run Python File button at the top right of the window:

Run python file

The Tutorial.py script showcases a simple application of Dips Scripting. Utilizing functions from the Dips Python API library, it:

  1. Launches the Dips application and a server at port 62535
  2. Accesses the Dips model
  3. Creates a Spot Mapping data set and adds it to the Orientation Data.
  4. Creates a Stereonet 2D view and in that view:
    1. Adds a Text Tool.
    2. Sets and gets the first Traverse visibility and properties.
    3. Sets the Contours visibility.

3.4 Install Libraries (Optional)

In Dips:

  1. Select Scripting > Manage Python Environment Manage Python from the ribbon.
  2. The RocScript WinPython Command Prompt will open.
    Install libraries in rocscript
  3. Check the installed libraries with the command:
pip list

Pre-installed libraries include:

  • The Dips Python API Library (i.e., DipsScripting 9.X.X on the list)
  • Dependency Python libraries:
    • colorama
    • grpcio
    • iniconfig
    • packaging
    • pluggy
    • protobuf
    • Pygments
    • pytest
    • pytest-mock
    • typing_extensions
  • Common Python libraries:
    • Pandas
    • Matplotlib
  1. If you wish to install more libraries, use the command to do so:
pip install [library name]

4.0 Method 2: Using your Own Environment

The Python environment is made up of two parts which need to be installed:

  1. The Python interpreter (Section 4.1 below)
  2. The Code Editor (Section 4.2 below)

4.1 Install Python

  1. Navigate to the Python downloads page (https://www.python.org/downloads/),
  2. Select the Download for the desired release version.
  3. Python 3.0.0 and later should be compatible; however, testing was performed using Python 3.11.2.
  4. Scroll down and select 'Windows installer (64-bit)'.
  5. Run the installer. Keep the defaults and select Install Now. Installation should complete successfully.

4.2 Install a Python Code Editor

Any code editor can be used, but we recommend you use Visual Studio Code.

To download and install Visual Studio Code:

  1. Navigate to the Download page (https://code.visualstudio.com/download)
    Install Visual Studio for Windows
  2. Select the Windows option
  3. Run the installer and complete the installation.

4.3 Configure Editor for Python

Visual Studio Code (VSCode) has extensions which can be installed.

  1. Navigate to the Extensions pane and search for Python.
    Configure editor for python
  2. Install the Python extension.
  3. Restart VSCode.

4.4 Install the Dips Library

  1. In VSCode, select View > Terminal in the menu to open a terminal.
    Install dips library
  2. Install the library using pip, which is a package manager that comes with Python:
pip install DipsScripting

If you are not using the latest release of Dips, you need to specify a library version that matches your Dips version. For example:

pip install "DipsScripting==9.1.0"

To find a list of available DipsScripting Python package versions, see Release History.

You can find your version of Dips by selecting Help > About in the Dips program.

The Dips Python API Library is now installed.

4.5 Open a File

In VSCode:

  1. Select File > Open File in the menu:
    open a file
  2. Select the Tutorial.py Python file from the tutorial folder directory located in the Examples > Tutorials folder in your Dips installation folder.

4.6 Run the file

To run the file:

  1. Click on the Run Python File button at the top right of the window.

You’ve successfully set up your Python environment to use Dips Scripting. You can build your own Python scripts for Dips now!

5.0 Resources

For more information on Dips Scripting, check out the following resources:

This concludes the tutorial.

Rocscience logo, click here to return to the homepage Portal Account Portal Account Portal Help Log In Log Out Home Shopping Cart icon Click here to search our site Click here to close Learning Tech Support RSInsight+ Logo Documentation Info Chevron Delete Back to Top View More" Previous Next Edit PDF File Calendar Location Language External Link Apply to ACC External Link Fees Video Click here to visit Rocscience's LinkedIn page Click here to visit Rocscience's YouTube page Click here to visit Rocscience's X page Click here to visit Rocscience's Facebook page Click here to visit Rocscience's Instagram page Click here to visit Rocscience's Reddit page Bookmark Network Scroll down for more Checkmark Download Print Back to top Single User Multiple Users RSLog RocFall3 CPillar Dips EX3 RocFall RocPlane RocSlope3 RocSupport RocTopple RS2 RS3 RSData RSPile RSWall RSSeismic Settle3 Slide2 Slide3 SWedge UnWedge RocTunnel3 RocSlope2 BlastMetrix ShapeMetriX FragMetriX TestLicense Commercial License Education License Trial License Shop safe & secure Money-back guarantee