Class NcUtil
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
RelNcFileTemplateReplacingKeyword
Keyword for replacing NC file path in templates.
public const string RelNcFileTemplateReplacingKeyword = "[NcFile]"
Field Value
Properties
LineBeginCsScriptRegex
Gets the regular expression for matching line-beginning C# script markers.
public static Regex LineBeginCsScriptRegex { get; }
Property Value
LineEndCsScriptRegex
Gets the regular expression for matching line-ending C# script markers.
public static Regex LineEndCsScriptRegex { get; }
Property Value
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
IFileLineIndexfile 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
stringThe NC line text to process.
cncBrand
CncBrandThe CNC brand to determine the comment style.
lineBeginCsScript
stringWhen this method returns, contains the line-beginning C# script if found; otherwise, null.
lineEndCsScript
stringWhen 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
stringThe NC line text to process.
brand
CncBrandThe CNC brand to determine the comment style.
ncComment
NcCommentWhen 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
stringThe NC line text to process.
ncComment
NcCommentWhen 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
NcLineThe current NcLine
preNcLine
NcLineThe previous NcLine
ncFlag
NcFlagThe 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
NcLineThe current NC line.
preNcLine
NcLineThe previous NC line.
ncFlag
NcFlagThe flag to check.
changingOn
booltrue 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
NcFlagThe 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
NcFlagThe flag to check.
changingOn
booltrue 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
NcLineThe current NC line.
preNcLine
NcLineThe previous NC line.
ncFlag
NcFlagThe flag to check.
keepingOn
booltrue 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
stringThe NC line text to process.
cncBrand
CncBrandThe 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)