Table of Contents

Class NcUtil

Namespace
Hi.Numerical
Assembly
HiUniNc.dll

Utility class for working with NC code.

public static class NcUtil
Inheritance
NcUtil
Inherited Members

Fields

NcNameTemplateReplacingKeyword

Keyword for replacing NC name in templates.

public const string NcNameTemplateReplacingKeyword = "[NcName]"

Field Value

string

RelNcFileTemplateReplacingKeyword

Keyword for replacing NC file path in templates.

public const string RelNcFileTemplateReplacingKeyword = "[NcFile]"

Field Value

string

Properties

LineBeginCsScriptRegex

Gets the regular expression for matching line-beginning C# script markers.

public static Regex LineBeginCsScriptRegex { get; }

Property Value

Regex

LineEndCsScriptRegex

Gets the regular expression for matching line-ending C# script markers.

public static Regex LineEndCsScriptRegex { get; }

Property Value

Regex

Methods

ApproachFloor<T>(IFileLineIndex, List<T>, IEnumerator<T>)

Get the value which is at the floor index (fileLineIndex) from src.

public static T ApproachFloor<T>(IFileLineIndex fileLineIndex, List<T> buffer, IEnumerator<T> src) where T : IFileLineIndex

Parameters

fileLineIndex IFileLineIndex

file line index

buffer List<T>

buffer. Only required capacity of 2.

src IEnumerator<T>

src

Returns

T

value at the floor index

Type Parameters

T

value type

GetSimCsScript(string, CncBrand, out string, out string)

Extracts C# scripts from the specified NC line text.

public static void GetSimCsScript(string ncLineText, CncBrand cncBrand, out string lineBeginCsScript, out string lineEndCsScript)

Parameters

ncLineText string

The NC line text to process.

cncBrand CncBrand

The CNC brand to determine the comment style.

lineBeginCsScript string

When this method returns, contains the line-beginning C# script if found; otherwise, null.

lineEndCsScript string

When this method returns, contains the line-ending C# script if found; otherwise, null.

GrabComment(string, CncBrand, out NcComment)

Extracts and removes a comment from the given NC line text based on the CNC brand.

public static string GrabComment(string srcNcLineText, CncBrand brand, out NcComment ncComment)

Parameters

srcNcLineText string

The NC line text to process.

brand CncBrand

The CNC brand to determine the comment style.

ncComment NcComment

When this method returns, contains the extracted comment, or null if no comment was found.

Returns

string

The NC line text with the comment removed if found; otherwise, the original text.

GrabHeadPercentComment(string, out NcComment)

Extracts and removes a head percent comment from the given NC line text.

public static string GrabHeadPercentComment(string ncLineText, out NcComment ncComment)

Parameters

ncLineText string

The NC line text to process.

ncComment NcComment

When this method returns, contains the extracted comment, or null if no comment was found.

Returns

string

The NC line text with the comment removed if found; otherwise, the original text.

IsFlagChanging(NcLine, NcLine, NcFlag)

Determines if a flag is changing between two NcLines

public static bool IsFlagChanging(this NcLine curNcLine, NcLine preNcLine, NcFlag ncFlag)

Parameters

curNcLine NcLine

The current NcLine

preNcLine NcLine

The previous NcLine

ncFlag NcFlag

The flag to check

Returns

bool

True if the flag is changing, false otherwise

IsFlagChanging(NcLine, NcLine, NcFlag, bool)

Checks if the flag is changing with a specific direction (on or off) between two NC lines.

public static bool IsFlagChanging(this NcLine curNcLine, NcLine preNcLine, NcFlag ncFlag, bool changingOn)

Parameters

curNcLine NcLine

The current NC line.

preNcLine NcLine

The previous NC line.

ncFlag NcFlag

The flag to check.

changingOn bool

true if flag set to on; otherwise, the flag set to off

Returns

bool

True if the flag is changing in the specified direction; otherwise, false.

IsFlagChanging(LinkedListNode<NcLine>, NcFlag)

Determines if a flag is changing in the current NcLine node compared to the previous node

public static bool IsFlagChanging(this LinkedListNode<NcLine> curNcLineNode, NcFlag ncFlag)

Parameters

curNcLineNode LinkedListNode<NcLine>

The current NcLine node

ncFlag NcFlag

The flag to check

Returns

bool

True if the flag is changing, false otherwise

IsFlagChanging(LinkedListNode<NcLine>, NcFlag, bool)

Checks if the flag is changing with a specific direction (on or off).

public static bool IsFlagChanging(this LinkedListNode<NcLine> curNcLineNode, NcFlag ncFlag, bool changingOn)

Parameters

curNcLineNode LinkedListNode<NcLine>

The current NC line node.

ncFlag NcFlag

The flag to check.

changingOn bool

true if flag set to on; otherwise, the flag set to off

Returns

bool

True if the flag is changing in the specified direction; otherwise, false.

IsFlagKeeping(NcLine, NcLine, NcFlag, bool)

Checks if the flag is keeping the same state between two NC lines.

public static bool IsFlagKeeping(this NcLine curNcLine, NcLine preNcLine, NcFlag ncFlag, bool keepingOn)

Parameters

curNcLine NcLine

The current NC line.

preNcLine NcLine

The previous NC line.

ncFlag NcFlag

The flag to check.

keepingOn bool

true if checking for kept on state; otherwise, checking for kept off state

Returns

bool

True if the flag is keeping the specified state; otherwise, false.

RemoveAllCsScript(string, CncBrand)

Removes all C# script markers and their contents from the specified NC line text.

public static string RemoveAllCsScript(string ncLineText, CncBrand cncBrand)

Parameters

ncLineText string

The NC line text to process.

cncBrand CncBrand

The CNC brand to determine the comment style.

Returns

string

The NC line text with all C# scripts removed.

SetTagNumber(ref string, string, double, string)

SetTagNumberWithoutDecimalTailZero.

public static void SetTagNumber(ref string ncLineTextWithoutComment, string tag, double tagNumber, string tagNumberFormat)

Parameters

ncLineTextWithoutComment string
tag string
tagNumber double
tagNumberFormat string