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
fileLineIndexIFileLineIndexfile line index
bufferList<T>buffer. Only required capacity of 2.
srcIEnumerator<T>src
Returns
- T
value at the floor index
Type Parameters
Tvalue 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
ncLineTextstringThe NC line text to process.
cncBrandCncBrandThe CNC brand to determine the comment style.
lineBeginCsScriptstringWhen this method returns, contains the line-beginning C# script if found; otherwise, null.
lineEndCsScriptstringWhen 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
srcNcLineTextstringThe NC line text to process.
brandCncBrandThe CNC brand to determine the comment style.
ncCommentNcCommentWhen 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.
GrabDoubleABC(ref string, bool)
public static Vec3d GrabDoubleABC(ref string text, bool enableIntegerShrink)
Parameters
Returns
GrabDoubleXYZ(ref string, bool)
public static Vec3d GrabDoubleXYZ(ref string text, bool enableIntegerShrink)
Parameters
Returns
GrabFlag(ref string, string)
public static bool GrabFlag(ref string text, string tag)
Parameters
Returns
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
ncLineTextstringThe NC line text to process.
ncCommentNcCommentWhen 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
curNcLineNcLineThe current NcLine
preNcLineNcLineThe previous NcLine
ncFlagNcFlagThe 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
curNcLineNcLineThe current NC line.
preNcLineNcLineThe previous NC line.
ncFlagNcFlagThe flag to check.
changingOnbooltrue 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
curNcLineNodeLinkedListNode<NcLine>The current NcLine node
ncFlagNcFlagThe 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
curNcLineNodeLinkedListNode<NcLine>The current NC line node.
ncFlagNcFlagThe flag to check.
changingOnbooltrue 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
curNcLineNcLineThe current NC line.
preNcLineNcLineThe previous NC line.
ncFlagNcFlagThe flag to check.
keepingOnbooltrue 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
ncLineTextstringThe NC line text to process.
cncBrandCncBrandThe 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)