grail.ip.reserves Module

Version: 16.2

Table of Contents

Overview

The reserves module provides access to the MineSight® Interactive Planner (MSIP) reserve information for an MSIP session.

The main purpose of this module is to provide access to two important dictionaries,

  1. The reserves dictionary.
  2. The equipment dictionary.

Rarely should these dictionaries by access directly by the script writer. Instead the script writer should use the grail.ip.reslib library for working with the reserves dictionary, and the grail.ip.equtils for working with the equipment dictionary.

Example of MineSight® IP Script Initialization

In order to use this module effectively you will need to perform the following two steps,

  1. You must get a handle to the current reserves reference.
  2. You must use that handle to get the reserves dictionary.

In Python code this would look like,

hres = reserves.hGetCurResRef()
dres = reserves.dGetRes(hres)

Functions

hGetCurResRef()
Returns the a current handle that can be used to get the reserves dictionary. See Example of MineSight® IP Script Initialization.
dGetRes(hres)
Given the handle, hres, return a reserves dictionary (see Reserves Dictionary). This function works with the hGetCurResRef() function.k
vRefreshPlan()

Triggers a plan refresh from the database. This call is reentrant, meaning you can call and get the new modified dRes after making the refresh call to get the newly loaded data. Any existing dRes structures obtained from before the refresh call will NOT reflect the reloaded data.

As an example consider the following,

# Initially, get our handle on the reserves dictionary.
hRes = reserves.hGetCurResRef()
dRes = reserves.dGetRes(hRes)

# ... later ...

reserves.vRefreshPlan()
hRes_r = reserves.hGetCurResRef()
dRes_r = reserves.dGetRes(hRes)

in the above example, as soon as you execute vRefreshPlan, the value of hRes and dRes become invalid. The hRes_r and dRes_r now have the new plan information stored within them.

To simplify the above example, you could have simply done the following,

# Refresh our handle on the reserves dictionary.
reserves.vRefreshPlan()
hRes = reserves.hGetCurResRef()
dRes = reserves.dGetRes(hRes)

and now the hRes and dRes will reference the correct reserves dictionary.

vDeleteCut(gkey)
Deletes cut which corresponds to the gkey provided.
vCreatePartialsFile(cut_index, filename)
Given a cut's cut_index from the dRes dictionary and a filename, this function will create a corresponding partials file.
dGetGeometry(hres, cutindex)

Returns the geometry dictionary for the indexed cut. The data dictionary contains the following keys,

Dictionary Keys:
Planar
Either 0 or 1.
Type
Can be either "Polyline", "Polygon", "Shell"
NumPoints
Indicates the number of points in the point list.
PointList

A list of points as triplet lists, in the form,

[[x0, y0, z0], ..., [xN, yN, zN]]
NumFaces
The number of faces in the face list.
FaceList

A list of vertex indice triples. In the form,

[[v0_0, v0_1, v0_2], ..., [vN_M, ...]]

where the first each triplet corresponds to a face.

Note

That the face list definition used above is not the same as the one used in the grail.ag module.

dGetCacheGeometry()
Returns cached geometry for the current cut in the same format as dGetGeometry above.
dGetGeomLimits(hRes, index)

Returns a dictionary that describes the limits (bounding box) for the cut at the given index. Dictionary keys used are,

  • Easting.min
  • Easting.max
  • Northing.min
  • Northing.max
  • Elevation.min
  • Elevation.max

These values report 3-D box that inscribes the cut.

dGetEquipInfo(geometrycutkey, materialname, number)

Returns the a dictionary containing the equipment information for a given material within the given geometry cut key. An example of using this would be,

cut = dres['cuts'][0] # first cut

for material in reslib.getmaterialsbycut(dres, cut):
   
for num in range(len(material['cutoffs'])):
      
equipdict = reserves.dGetEquipInfo(cut['geomkey'],
                                         
material['name'],
                                         
num)

See the grail.ip.equtils module for information about working with the equipment dictionary.

iSetEquipInfo(geometrycutkey, cutkey, cutoffindex, equipdict)
Sets the equipment dictionary for a given geometry cut.
iReplaceValid()
xxx -- needs documentation.
vClearTransBuff()
xxx -- needs documentation.

Reserves Dictionary

In the following listing, each indentation either represents another Python dictionary or Python listing.

Note

It is not recommended that you work with the reserves dictionary directly unless you really have to. The grail.ip.reslib module provides methods to make working with the dictionary much easier.

If you choose to work with the dictionary directly the internal organization is not always guaranteed to work from MineSight® Grail version to version.

The reserves dictionary is listed as follows,

planname : string
The plan name.
volredpct : integer
True if volume reduction / mined out is represented by a percent.
imperial : integer
Imperial flag.
curcut : integer
Current cut index; -1 if there is no current cut.
numcuts : integer
Number of cuts.
numareas : integer
Number of areas.
curarea : integer
The current area.
curminearea : string
The current mining area.
curperiod : string
The current period.
attribnames : list
List of attribute names.
cuts : list

List of cut dictionaries (use numerical index).

geomkey: integer
Key to geometry segment.
planelabel : string
Plane label.
name : string
The cut's name.
area : string
The cut's area.
matset : string
Material set name.
miningarea : string
The cut's mining area.
period : string
The cut's period.
geomcreation : string
The cut's Geom Info. Typically this refers to the seams in a GSM.
cutSurfaceSet: string
The cut's Surface Set.
numres : integer
Number of cut reserves.
numcustom : integer
Number of the cut's custom attributes.
attributes : list

List of customs attribute dictionaries.

name : string
Attribute name.
type : string
Attribute type. It can be one of 'integer', 'double' or 'string'.
value : any
Value of attribute. The type of attribute is dependent on the the value in the type field.
reserves : list

A listing of reserve dictionaries with the following keys,

material : string
Material name.
zoneidx : <xxx-type>
Zone index number.
numgrades : integer
Number of grades.
cutoff : float
Cutoff index.
tons : float
Tons of this reserve item.
volume : float
Volume of this reserve item.
numblocks : float
Number of blocks used to calculate these values.
nullflag : list
List of null flags. If the grade value in gradevalues is actually a null and not a zero this flag is set to true.
gradenames : list
Listing of grade names. Each grade name is a string.
gradevalues : list
List of grade values. Each grade value is a float.
areas : list of dictionaries

A list of area dictionaries where the keys are defined as follows,

name : string
Area name.
thicknessitem : string
Thickness item name.
volreditem : string
Volume reduction item name.
partialsitem : string
Partials item name.
model : integer
Model handle.
partialsmodel : integer
Partials model handle.
flags : integer

Warning

Do not use.

volreduction : integer
Volume reduction flag. This flag is 1 if volume reduction item was used.
items : list

List of ore and waste items only 1 in simple case.

pctitem : string
Percent item name.
zoneitem : string
Zone item name.
orepctitem : string
Ore percent item (only used in single ore percent case).
densityitem : string
Density item.
sgflag : integer
This is 1 if using specific gravity (SG).
waste : integer
This is 1 if waste in the multi-percent case.
priority : integer
Numeric priority, values can be repeated.
numgrades : integer
Num grades.
grades : list

List of grades dictionaries, where the keys are defined as follows,

name : string
Grade name.
accum : integer
Flag accumulated versus averaged.
thick : integer
This is flag for thickness grade so average with numblocks.
materialsets : list of dictionaries

List of material set dictionaries where the keys are defined as follows,

name : string
Material set name.
materials : list of dictionaries

The material dictionary keys are defined as follows,

name : string
Material name.
index : integer
Materials index.
waste : integer
Set to 1 if waste.
default : integer
Set to 1 if this is the default material.
numcutoffs : integer
Number of cutoffs.
density : float
Default density for this material.
cutoffs : list
A listing of cutoff values (each element is a float).