HowTo: Create a Polygon in a Geometry MSR

Version: 16.2

Table of Contents

Preface

This document describes the process of creating a Polygon within a geometry MSR via the embedded grail.ms3d.datamanager module. We will review the steps that are required to in order to create an polygon element, a geometry object and inserting that element into the geometry object.

This document will not cover using the grail.data.geometry module for manipulating a geometry file. Instead it will concentrate on using the MS3D datamanager.

Assumptions

It is assumed that you are familar with MineSight® 3D, and have an understanding of the basic mechanics behind python scripting.

To execute a MineSight® Grail embedded script you must run the script inside the MineSight® 3D. Any script that references the grail.ms3d module, has this requirement.

See HowTo: Create an Embedded Script for more details on MineSight® Grail Embedded scripting.

Getting Started

The easiest way to tackle this is to show a little example that inserts a small polygon triangle. It will also apply a name and material to that element.

from grail.ms3d import datamanager
from grail.ms3d import element

# (1)
pointlist = [[100, 0, 0], [0, 100, 0], [0, 0, 100]]
polygon = element.create_polygon(pointlist)

# (2)
polygon.set_name_and_material(
    
"pit base", "pit base", create_if_not_exist=True
    
)

# (3)
geo = datamanager.create_or_open_geometry("\\geometry1")

# (4)
geo.add_elements([polygon])

geo.close()

Now lets go over each of the major features,

  • (1) The first thing we do is create a Element object with our point list. The Geometry MSR's talk in Element objects so we need to make sure we wrap our data properly.
  • (2) Attributed element's should have a name and a material. By using the set_name_and_material we ensure both of them are set at the same time. The create_if_not_exist flag is useful for automatically generating a material if it is not already in the material table.
  • (3): Getting our GeometryMOB (Geometry MineSight Object). This object is where we will place our elements. The create_or_open_geometry will either create a new one or open an existing one within the datamanager. All paths are relative to the datamanager.
  • (4): Add the elements. We now use the add_elements to add our element to the GeometryMOB object. The add_elements can take a list of multiple elements, but in this case we only have one so we just create a list on the fly.

After the above code is executed, you should have a "geometry1" object within your datamanager, and in that object you will have a triangle that will have a name and material of "pit base".

The grail.ms3d.element module as the ablity to create labels, shells (surfaces), markers and polylines. The same logic shown above can be applied to these modules.