In the Designer tab > Display panel > Labels section > Text dropdown > there is a preloaded list of automatic labels for the level hierarchy and reserves fields. We can add to this list by configuring custom labels.
In Designer tab > Display panel > Labels section > Text dropdown > gear icon.
Click the blue plus icon to add a new label.
Rename the label to "Ore Tonnes".
Paste the sample formula into the code editor.
Press OK to finish.
Double click in the Available Formulas for code hints.
Ore Tonnes Label Example
Multi-Line Label
using System; using Alastri.RR.Ui; using Alastri.RR.Service; public class LabelFormat : ILabel { public string GetLabel(ShadingContext context) { return "Blast " + context.GetLevelName("Solid") + "\n" + context.GetReserveValue("Volume").ToString("#,##0") + " bcm \n" + context.GetReserveValue("DryTonnes").ToString("#,##0") + "t"; } }
Area / Perimeter Ratio
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"); } }
Ore Tonnes Label
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> parcels = context.GetParcels(); 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"); } }
Majority Parcel
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; } }
Ore Ratio
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%"); } }
Grade Control naming convention
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; } } }
Calculate Blast Type
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.Key.Substring(0,1); //first letter of parcel if(!newBins.TryGetValue(newBin, out double volume)) { newBins[newBin] = 0; } newBins[newBin] += parcel.Value; } //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; } }