Custom Labels

In the Network tab in the Display panel, locate Labels and Shadings fields and click on the dropdown: there is a preloaded list of preconfigured labels and shadings for Segments, Blocks, Nodes and Joins. We can add to this list by configuring custom labels and shadings.

Follow the links below to see examples of preconfigured labels:

 

Adding a Custom Label

  1. Click the gear icon on the right from the Label dropdown.

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

  3. Rename the label as desired.

  4. Paste the sample formula into the code editor window.

  5. Click OK to finish.

  6. Select the newly added label from the Label: field dropdown.

  7. To view the label, make sure you the Labels eye toggle is enabled.

Note that you can change label colors and alignments by pressing the Aa button on the right:

Available Formulas

In the Formulas tab, there is a list of available formulas. Double click on one of the code hints and paste it in the “return” row.

  • To convert data of the “double” type to the “string” type, you’ll need to use “.ToString()” method.

  • To display a certain number of decimals in the text label, use formats like “"#,##0.00"“.

  • To add a new line in the label, use ““\n”“.

  • To add any other text in the label, use +””…””, for example, “ + " m"“;.

Segments Distance Label

Copy
using System;
using Alastri.HaulInfinity.ScriptExtensions.Shading;

public class CustomLabel : ISegmentLabel
{         
    public string GetLabel(ISegmentShadingContext context)
    {
        return (context.Distance).ToString("#,##0.00") + " m"

    }
}


Segments Distance Label

 

Segments Gradient Label

Copy
using System;
using Alastri.HaulInfinity.ScriptExtensions.Shading;

public class CustomLabel : ISegmentLabel
{         
    public string GetLabel(ISegmentShadingContext context)
    {
        return (context.GradePct).ToString("#,##0.00") + "%"
    }
}


Segments Gradient Label

 

Segments Custom Property

Copy
using System;
using Alastri.HaulInfinity.ScriptExtensions.Shading;

public class CustomLabel : ISegmentLabel
{         
    public string GetLabel(ISegmentShadingContext context)
    {
        return (context.GetCustomProperty("Region")); 
    }
}


Segments Custom Property

 

 

Blocks Name

Copy
using System;
using Alastri.HaulInfinity.ScriptExtensions.Shading;

public class CustomLabel : IBlockLabel
{         
    public string GetLabel(IBlockShadingContext context)
    {
        string name = context.FullName;
        string[] nameParts = name.Split('\\');
        if(nameParts.Length <5) return "";
        string pitName= nameParts[2];
        string benchName= nameParts[4];
        string blastName= nameParts[5];
        return string.Concat(pitName,'-',benchName,'-',blastName);
    }
}


Blocks Name

 

Blocks Auto Joins Number

Copy
using System;
using Alastri.HaulInfinity.ScriptExtensions.Shading;

public class CustomLabel : IBlockLabel
{         
    public string GetLabel(IBlockShadingContext context)
    {
        return  (context.AutoJoinCount).ToString(); 
    }
}


Blocks Auto Joins Number

 

Nodes Data Source

Copy
using System;
using Alastri.HaulInfinity.ScriptExtensions.Shading;

public class CustomLabel : INodeLabel
{         
    public string GetLabel(INodeShadingContext context)
    {
        return context.DataSource;
    }
}


Nodes Data Source

 

Nodes Coordinates

Copy
using System;
using Alastri.HaulInfinity.ScriptExtensions.Shading;

public class CustomLabel : INodeLabel
{         
    public string GetLabel(INodeShadingContext context)
    {
    return "(" + context.X.ToString("#,##0.00") + " | " + context.Y.ToString("#,##0.00") + " | " + context.Z.ToString("#,##0.00") + ")";
    }
}


Nodes Coordinates