Create Custom Labels
In the Reserves tab in the Viewport Display panel locate Labels field and press its drop-down; 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.
Adding Custom Label
-
Click the gear icon to the right of the Label drop-down.
-
Click the blue plus icon to add a new label.
-
Rename the label to "Record".
-
Paste the sample formula into the code editor.
-
Double click in the Available Formulas for code hints.
-
Click OK to finish.
Custom ID
using System;
using Alastri.Patri;
using Alastri.Scheduler.ScriptExtensions;
using System.Collections.Generic;
using Alastri.Scripting;
using Alastri.SchedulingCore;
public class Label : ILabelTextProvider
{
public string GetLabel(RecordAndShadingContext rsc)
{
var name = rsc.Record.GetNames();
var mine = name[1];
var pit = name[2];
var stage = name[3];
var bench = name[4];
var blast = name[5];
return "Id: " + mine + "_" + pit + "_" + stage + "_" + bench + "_" + blast;
}
}
Pit_Bench
using System;
using Alastri.Patri;
using Alastri.Scheduler.ScriptExtensions;
using System.Collections.Generic;
using Alastri.Scripting;
using Alastri.SchedulingCore;
public class Label : ILabelTextProvider
{
public string GetLabel(RecordAndShadingContext rsc)
{
if(rsc.Record.Table.HoldsDumps)
return "";
var Name = rsc.Record.GetNames();
var pit = Name[1];
var bench = Name[3];
return pit + "_" + bench;
}
}
GC
using System;
using Alastri.Patri;
using Alastri.Scheduler.ScriptExtensions;
using System.Collections.Generic;
using Alastri.Scripting;
using Alastri.SchedulingCore;
public class Label : ILabelTextProvider
{
public string GetLabel(RecordAndShadingContext rsc)
{
PatriRecord record = rsc.Record;
if(record.Table.HoldsDumps || !record.IsLeaf)
return "";
PatriRowField dataSourceField = rsc.Record.Database.FindRow<PatriRowField>("misc_dataSource");
string dataSource = record.GetStringValue(dataSourceField.Field);
bool isGradeControl = !dataSource.Equals("BlockModel");
if (isGradeControl)
{
return $"GC_{record.GetFullName()}";
}
return record.GetFullName();
}
}
Tonnes and %
using System;
using Alastri.Patri;
using Alastri.SchedulingCore;
using Alastri.Scheduler.ScriptExtensions;
using System.Collections.Generic;
using Alastri.Scripting;
public class Label : ILabelTextProvider
{
PatriRowField _volume;
PatriRowField _dryTonnes;
PatriRowField _fe;
public string GetLabel(RecordAndShadingContext rsc)
{
_volume = rsc.Record.Database.FindRow<PatriRowField> ("Mining_volume");
_dryTonnes = rsc.Record.Database.FindRow<PatriRowField> ("Mining_dryTonnes");
_fe = rsc.Record.Database.FindRow<PatriRowField> ("Mining_grades_fe");
double volume = rsc.Record.GetDoubleValue(_volume.Field, (IParcelSubset) null);
double dryTonnes = rsc.Record.GetDoubleValue(_dryTonnes.Field, (IParcelSubset) null);
double fe = rsc.Record.GetDoubleValue(_fe.Field, (IParcelSubset) null);
if (volume > 50000)
{
return dryTonnes.ToString("###,0") + " t" + "\n" +
fe.ToString("###,0.00") + " %";
}
return"";
}
}
Grades
using System;
using Alastri.Patri;
using Alastri.Scheduler.ScriptExtensions;
using System.Collections.Generic;
using Alastri.Scripting;
using Alastri.SchedulingCore;
public class Label : ILabelTextProvider
{
PatriField fe;
PatriField si;
public string GetLabel(RecordAndShadingContext rsc)
{
fe ??= rsc.ShadingContext.Database.FindField("grades_fe");
si ??= rsc.ShadingContext.Database.FindField("grades_si");
return "Fe: " + rsc.Record.GetDoubleValue(fe, ParcelAll.Default).ToString("#,##0.00") + "%" + "\n" +
"Si: " + rsc.Record.GetDoubleValue(si, ParcelAll.Default).ToString("#,##0.00") + "%" ;
}
}
One Name Label per Dump
using System;
using Alastri.Patri;
using Alastri.Scheduler.ScriptExtensions;
using System.Collections.Generic;
using Alastri.Scripting;
using Alastri.SchedulingCore;
public class Label : ILabelTextProvider
{
public string GetLabel(RecordAndShadingContext rsc)
{
string dumplabellocation = rsc.Record.GetStringValue(rsc.Record.Database.FindField("misc_DumpLabelLocation"));
if(rsc.Record.Table.HoldsDumps && dumplabellocation == "True")
{
var Name = rsc.Record.GetNames();
var Dump = Name[1];
var Lift = Name[2];
return Dump;
}
else
{
return "";
}
}
}
Note, that this label requires some configuration n RR and mappings:
-
RR > Setup > Blast Properties > create a new property (“DumpName” for example) of a Choice type.
-
Input Comma Separated Choices: True,False.
-
Select “False” as a Default Value.
-
-
RR > Designer > select one lift of each dump > pick one random block and change the new property to true.
-
ATS > Setup > Misc Fields > create a field and give it a name to be used later in your label script (e.g., DumpLabelLocation).
-
ATS > Setup > Map Fields > map this Misc Field to the blast property created in RR.
-
ATS > Reserves > create a new label and copy the label code provided above.