User Guide#


Python Tool Pro requires a connection to be established from the preferred client-side Python IDE to the Python Tool Pro server in Petrel. Petrel domain objects are accessed from the external Python IDE and the scripts are executed outside of Petrel. The results of the Python scripts can then be streamed back to Petrel.

Python Tool Pro is using Cegal Hub to establish a connection to Petrel. The Hub client (Petrel connector application) needs to establish a connection to the Hub server. Once this connection is established, the Python Tool Pro client can connect to the active Petrel instance through the Hub server. For more information on the connection to a Hub Server go to the Hub Getting Started chapter.

Establish a PetrelConnection with Python Tool Pro#

To establish a connection to Petrel we will use the class PetrelConnection. We will assign a Python variable called ‘ptp’. We can then use the Python properties and methods of the variable ‘ptp’ to access various Petrel domain objects or get information about the connected Petrel project.

from cegalprizm.pythontool import PetrelConnection
ptp = PetrelConnection()


The distinction between Python properties and Python methods is subtle. Syntactically, method calls always end in parentheses - () - whereas properties don’t. Generally, properties indicate an intrinsic property of the object which is not going to change: the Python API uses properties to access dimensions, names etc which are effectively never going to change in the lifetime of a script. Method calls are requests for data or instructions to do something, and most often contain parameters which specify what kind of data. The petrel_name attribute is an example of something that should never change in the lifetime of a script.


Python properties and methods are also referred to as Python attributes and functions, respectively.

In the following chapters we will go through the properties and methods of the class PetrelConnection to access various Petrel domain objects. We will also cover different methods and properties of the domain object classes and explain basic operations.