Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

Tip

In the Designer tab in Display panel locate Labels section and press Text dropdown: there is a preloaded list of automatic labels for the level hierarchy and reserves fields.

...

Adding Custom Label

...

We can add

...

Press the gear icon on the right from Text dropdown.

...

to this list by configuring custom labels displaying various data and properties.


Table of Contents
Image Added

Adding Custom Labels

  1. Select the gear icon next to the Text dropdown. This opens the configuration dialog.

  2. Press the blue plus icon to add a new label.

  3. Rename the label to "Ore Tonnes" for example.

  4. Paste the sample formula into the code editor.

  5. Double click in the Available Formulas for code hints.

  6. Press

...

Custom Labels will appear orange in the list.

...

  1. the Test button to make sure your code is correct. Any errors found will be shown in the Errors panel and won’t let you to proceed.

  2. Fix any errors detected, run test again and press OK to accept.

Image Added

In the Labels panel on the right, toggle eye icon to show labels and from the Text dropdown select the label you have created - Ore Tonnes (Note that custom shadings are shown in bold orange, while standard shadings are shown in normal black).

Select bench from the tree on the left to display it in the viewport and review the result.

Image Added

Custom Labels Examples

See below a list of the most common custom labels you can copy and paste into your Code Editor, making some custom changes as required.

Multi-Line Label

Code Block
languagec#
using System;
using Alastri.RR.Ui;
using Alastri.RR.Service;

public class LabelFormat : ILabel
{         
    public string GetLabel(ShadingContext context)
    {
        return "Blast " + context.GetLevelName("

...

Blast") + "\n"
		+ context.GetReserveValue("Volume").ToString("#,##0") + " bcm \n"
		+ context.GetReserveValue("DryTonnes").ToString("#,##0") + "t";
    }
}

Image Added


Area / Perimeter Ratio

Code Block
languagec#
using System;
using Alastri.RR.Ui;
using Alastri.RR.Service;

public class LabelFormat : ILabel
{         
    public string GetLabel(ShadingContext context)
    {
        return (context.SurfaceArea / context.Perimeter).ToString("#,##0.00"); 
    }
}

Image Added


Ore Tonnes Label

Code Block
languagec#
using System;
using System.Collections.Generic;
using System.Linq;
using Alastri.RR.Ui;
using Alastri.RR.Service;

public class LabelFormat : ILabel
{   
    public string GetLabel(ShadingContext context)
    {
    List<string> temp = context.GetParcels();
	List<string> parcels = temp.ConvertAll(low => low.ToLowerInvariant());
	List<string> ores = new List<string>(){ "hg", "mg", "lg" };
		
	double oreTonnes = 0;
		
	foreach(var parcel in parcels)
	{
		if(ores.Any(ore => parcel.StartsWith(ore)))
		{
			oreTonnes += context.GetReserveValue("DryTonnes", parcel);
		}
	}
		
	return oreTonnes.ToString("#,##0");
    }
}

Image Added


Waste Tonnes Label

Code Block
languagec#
using System;
using System.Collections.Generic;
using System.Linq;
using Alastri.RR.Ui;
using Alastri.RR.Service;

public class LabelFormat : ILabel
{   
    public string GetLabel(ShadingContext context)
    {
    List<string> temp = context.GetParcels();
	List<string> parcels = temp.ConvertAll(low => low.ToLowerInvariant());
	List<string> waste = new List<string>(){ "w", "minw" };
		
	double wasteTonnes = 0;
		
	foreach(var parcel in parcels)
	{
		if(waste.Any(waste => parcel.StartsWith(waste)))
		{
			wasteTonnes += context.GetReserveValue("DryTonnes", parcel);
		}
	}
		
	return wasteTonnes.ToString("#,##0");
    }
}

Image Added


Majority Parcel

Code Block
languagec#
using System;
using Alastri.RR.Ui;
using Alastri.RR.Service;

public class LabelFormat : ILabel
{         
    public string GetLabel(ShadingContext context)
    {
        var parcels = context.GetParcels();
		
	string majorityParcel = "";
        double majorityTonnes = -1e7;
        foreach (var parcel in parcels)
        {
            double t = context.GetReserveValue("DryTonnes", parcel);
            if (t > majorityTonnes)
            {
                majorityTonnes = t;
                majorityParcel = parcel;
            }
        }
	return majorityParcel;
    }
}

Image Added


Ore Ratio

Code Block
languagec#
using System;
using System.Collections.Generic;
using System.Linq;
using Alastri.RR.Ui;
using Alastri.RR.Service;
 
public class LabelFormat : ILabel
{  
    public string GetLabel(ShadingContext context)
    {
        List<string> wasteList = new List<string>(){ "w", "lg1", "lg2", "lg3" };
        
        double oreTonnes = 0;
         
        foreach(var parcel in context.GetParcels())
        {
            if(!wasteList.Contains(parcel.ToLower()))
            {
                oreTonnes += context.GetReserveValue("DryTonnes", parcel);
            }
        }
        
	double allTonnes = context.GetReserveValue("DryTonnes");
		
        return allTonnes == 0 ? "0" : (oreTonnes / allTonnes).ToString("0.0%");
    }
}

Image Added


Grade Control

...

Naming Convention

Code Block
languagec#
using System;
using Alastri.RR.Ui;
using Alastri.RR.Service;

public class LabelFormat : ILabel
{        
    public string GetLabel(ShadingContext context)
    {
        string mine = context.GetLevelName("Mine");
        string pit = context.GetLevelName("Pit");
        string bench = context.GetLevelName("Bench");
        string blast = context.GetLevelName("Solid");
        string gradeBlock = context.GetSolidPropertyString("GradeBlock");

        if(context.ReservesDataSource.ToString() == "BlockModel")
        {
             return mine + "/" + pit + "/" + bench + "/" + blast;
        }
        else
        {
	     blast = blast.Split('_')[0];
             return mine + "/" + pit + "/" + bench + "/" + blast + "/" + gradeBlock;
        }
    }
}

Image Added


Calculate Blast Type

Code Block
languagec#
using System;
using System.Collections.Generic;
using System.Linq;
using Alastri.RR.Ui;
using Alastri.RR.Service;

public class LabelFormat : ILabel
{         
    Dictionary<string,double> parcelLookup = new Dictionary<string, double>();
    Dictionary<string,double> newBins = new Dictionary<string, double>();
	
    public string GetLabel(ShadingContext context)
    {
      parcelLookup.Clear();
      newBins.Clear();

      //organise parcels into bins
      foreach(var parcel in context.GetParcels())
      {
        	parcelLookup[parcel] = context.GetReserveValue("Volume", parcel); 
			
			string newBin = parcel.Substring(0,1); //first letter of parcel
				
			if(!newBins.TryGetValue(newBin, out double volume))
			{
				newBins[newBin] = 0;
			}
			newBins[newBin] += parcelLookup[parcel];
      }
		
      //find majority bin
      string bin = null;
      double max = -1;
		
      foreach(var newBin in newBins)
      {
        if(newBin.Value > max)
        {
          max = newBin.Value;
          bin = newBin.Key;
	}
      }
		
      return bin;
    }
}

Image Added


Export Name

Custom label including Mine - Pit - Stage names.

Code Block
languagec#
using System;
using Alastri.RR.Ui;
using Alastri.RR.Service;

public class LabelFormat : ILabel
{         
    public string GetLabel(ShadingContext context)
    {
        return context.GetLevelName("Mine") + "_" + context.GetLevelName("Pit") + "_" + context.GetLevelName("Stage");
    }
}

Image Added


Export Description

Custom label including Full name + Blast Property + Blast Type.

Code Block
languagec#

using System;
using Alastri.RR.Ui;
using Alastri.RR.Service;

public class LabelFormat : ILabel
{         
    public string GetLabel(ShadingContext context)
    {
        return context.GetFullName() + "/" + context.GetSolidPropertyString("InitialState") + "/" + context.BlastType;
    }
}

Image Added