Table of Contents

Class CircularMotionSyntax

Namespace
Hi.NcParsers.LogicSyntaxs
Assembly
HiMech.dll

Writes McArc motion for circular commands (ISO G02/G03). Detects motion mode from Flags, reads I/J/K center offsets or R radius from Parsing, computes arc center in program coordinates, and writes a one-shot MotionEvent (form + arc params) plus a modal MotionState (Term).

G02/G03 mode is modal (Group 01) — persists across blocks via Term. Arc parameters (I/J/K/R) are per-block and must be present in every arc block.

Must be placed before LinearMotionSyntax in the syntax chain. Both share the Group 01 motion slot; whichever writes a MotionEvent first claims it.

IsIjkAbsolute switches the I/J/K reading to absolute center coordinates (Heidenhain DIN/ISO — the ISO twin of the Klartext CC pole; the Heidenhain list sets it, every other brand keeps the offset default). In that mode the center is modal: letters not written in a block inherit the previous absolute pole (AbsoluteIjkPoleKey, carried by the brand's ModalCarrySyntax), a letter never written falls back to the arc start's component, a letters-free block that commands an endpoint continues the modal arc off the pole (a flags-only block stays motionless), a G91 block reads offsets again and breaks the pole chain, and the plane-normal letter is a center coordinate — never the per-turn helix pitch. Behavior mirrors HardNcLine.BuildArcNcArg + ArcNcArg.GetCenterOrCenterOnBeginPlane (HiUniNc 3.1.152.2) bit for bit.

public class CircularMotionSyntax : ISituNcSyntax, INcSyntax, IMakeXmlSource
Inheritance
CircularMotionSyntax
Implements
Inherited Members
Extension Methods

Examples

All cases below have the current block's ProgramXyz already set (as a prior ProgramXyzSyntax would have produced) and run with no #Previous:, so GetLastProgramXyz returns Vec3d.Zero. The G17 XY plane is implicit (no PlaneSelect section means GetPlaneNormalDir(JsonObject) returns 2 — the XY-plane default — so arc math runs with Z as the perpendicular axis).

G02 with I/J — quarter arc from (0,0,0) to (10,0,0) around (5,0,0); I=5 J=0 are incremental offsets from start to center. The G02 flag is consumed (Parsing removed once empty); MotionState + MotionEvent are written:

#BeforeBuild:
{
  "Parsing": { "Flags": ["G02"], "I": 5, "J": 0 },
  "ProgramXyz": { "X": 10, "Y": 0, "Z": 0 }
}
#AfterBuild:
{
  "ProgramXyz": { "X": 10, "Y": 0, "Z": 0 },
  "MotionState": { "Term": "G02" },
  "MotionEvent": {
    "Form": "McArc",
    "ArcCenter": { "X": 5, "Y": 0, "Z": 0 },
    "IsCcw": false,
    "AdditionalCircleNum": 0
  }
}
Modal carry of G02: no motion flag on the current block but a #Previous: MotionState.Term = "G02" tells us we are still in circular mode. I/J on the current block describe the arc the same way: #Previous:
{ "MotionState": { "Term": "G02" } }
#BeforeBuild:
{
  "Parsing": { "I": 5, "J": 0 },
  "ProgramXyz": { "X": 10, "Y": 0, "Z": 0 }
}
#AfterBuild:
{
  "ProgramXyz": { "X": 10, "Y": 0, "Z": 0 },
  "MotionState": { "Term": "G02" },
  "MotionEvent": {
    "Form": "McArc",
    "ArcCenter": { "X": 5, "Y": 0, "Z": 0 },
    "IsCcw": false,
    "AdditionalCircleNum": 0
  }
}
No I/J/K/R on the block — the per-block arc data is missing, so the syntax bails out early; the G02 flag stays in Parsing.Flags for some other syntax to act on (or to surface as residue if no one does): #BeforeBuild:
{
  "Parsing": { "Flags": ["G02"] },
  "ProgramXyz": { "X": 10, "Y": 0, "Z": 0 }
}
#AfterBuild:
{
  "Parsing": { "Flags": ["G02"] },
  "ProgramXyz": { "X": 10, "Y": 0, "Z": 0 }
}
R-format degenerate (chord = 2R, semicircle): start (0,0,0) → end (10,0,0), R=5. perpDistSq resolves to 0 so the computed center collapses to the chord midpoint (5,0,0); no sqrt drift on this branch: #BeforeBuild:
{
  "Parsing": { "Flags": ["G02"], "R": 5 },
  "ProgramXyz": { "X": 10, "Y": 0, "Z": 0 }
}
#AfterBuild:
{
  "ProgramXyz": { "X": 10, "Y": 0, "Z": 0 },
  "MotionState": { "Term": "G02" },
  "MotionEvent": {
    "Form": "McArc",
    "ArcCenter": { "X": 5, "Y": 0, "Z": 0 },
    "IsCcw": false,
    "AdditionalCircleNum": 0
  }
}
R-format non-trivial: G02 90° arc from (0,0,0) to (10,10,0) with R=10. The center comes from the cross-product + sqrt + normalize path inside ResolveCenterFromSignedRadius(Vec3d, Vec3d, int, bool, double), but for this particular axis-aligned chord the rounding errors cancel and the center lands at exactly (10, 0, 0) — i.e. no ULP drift here, in contrast to e.g. McAbcCyclicPathSyntax's rad/deg round-trip: #BeforeBuild:
{
  "Parsing": { "Flags": ["G02"], "R": 10 },
  "ProgramXyz": { "X": 10, "Y": 10, "Z": 0 }
}
#AfterBuild:
{
  "ProgramXyz": { "X": 10, "Y": 10, "Z": 0 },
  "MotionState": { "Term": "G02" },
  "MotionEvent": {
    "Form": "McArc",
    "ArcCenter": { "X": 10, "Y": 0, "Z": 0 },
    "IsCcw": false,
    "AdditionalCircleNum": 0
  }
}
G03 CCW with I/J — same geometry as case 0 (start (0,0,0), end (10,0,0), I=5 J=0 → center (5,0,0)) but the G03 flag flips IsCcw to true. Direction is the only differentiating output; arc-center math is unchanged: #BeforeBuild:
{
  "Parsing": { "Flags": ["G03"], "I": 5, "J": 0 },
  "ProgramXyz": { "X": 10, "Y": 0, "Z": 0 }
}
#AfterBuild:
{
  "ProgramXyz": { "X": 10, "Y": 0, "Z": 0 },
  "MotionState": { "Term": "G03" },
  "MotionEvent": {
    "Form": "McArc",
    "ArcCenter": { "X": 5, "Y": 0, "Z": 0 },
    "IsCcw": true,
    "AdditionalCircleNum": 0
  }
}
Full circle G02 — start == end (both (0,0,0)), I=5 J=0 places center off-start at (5,0,0). Plane-restricted closure (IsClosedOnPlane(Vec3d, Vec3d, int, double)) flips AdditionalCircleNum to 1 so a downstream motion semantic knows to draw the closed loop: #BeforeBuild:
{
  "Parsing": { "Flags": ["G02"], "I": 5, "J": 0 },
  "ProgramXyz": { "X": 0, "Y": 0, "Z": 0 }
}
#AfterBuild:
{
  "ProgramXyz": { "X": 0, "Y": 0, "Z": 0 },
  "MotionState": { "Term": "G02" },
  "MotionEvent": {
    "Form": "McArc",
    "ArcCenter": { "X": 5, "Y": 0, "Z": 0 },
    "IsCcw": false,
    "AdditionalCircleNum": 1
  }
}
Fanuc L parameter (helix turn count, 1-based) — L3 on a start==end closed loop means three total turns, so AdditionalCircleNum = L − 1 = 2. Matches the legacy HardNc reading; the L parameter is consumed alongside I/J/K/R: #BeforeBuild:
{
  "Parsing": { "Flags": ["G02"], "I": 5, "J": 0, "L": 3 },
  "ProgramXyz": { "X": 0, "Y": 0, "Z": 0 }
}
#AfterBuild:
{
  "ProgramXyz": { "X": 0, "Y": 0, "Z": 0 },
  "MotionState": { "Term": "G02" },
  "MotionEvent": {
    "Form": "McArc",
    "ArcCenter": { "X": 5, "Y": 0, "Z": 0 },
    "IsCcw": false,
    "AdditionalCircleNum": 2
  }
}
K-as-pitch helix on G17 (XY plane) — when the plane-normal axis letter (K for G17, J for G18, I for G19) is present on an IJK-format arc, it is the per-turn axial pitch, not a center offset. Here K = −3 mm/turn over ΔZ = −9 mm gives AdditionalCircleNum = floor(−9 / −3) = 3. The center stays on the begin-plane (Z = 0) — ResolveCenterFromIjk zeros the plane-normal component before adding to begin. Matches the legacy HardNc reading: #BeforeBuild:
{
  "Parsing": { "Flags": ["G02"], "I": 5, "J": 0, "K": -3 },
  "ProgramXyz": { "X": 0, "Y": 0, "Z": -9 }
}
#AfterBuild:
{
  "ProgramXyz": { "X": 0, "Y": 0, "Z": -9 },
  "MotionState": { "Term": "G02" },
  "MotionEvent": {
    "Form": "McArc",
    "ArcCenter": { "X": 5, "Y": 0, "Z": 0 },
    "IsCcw": false,
    "AdditionalCircleNum": 3
  }
}
Absolute I/J (IsIjkAbsolute = true on the SUT — the Heidenhain DIN/ISO reading; values taken from a real production program): I/J ARE the center's program coordinates, the center is locked onto the begin plane (Z from the previous block), the post-inheritance letters are recorded as the modal AbsoluteIjkPole section and the event is stamped IsIjkAbsolute for the NcOpt splition write-back (the arc start comes from the predecessor's MachineCoordinateState — the modal anchor GetLastProgramXyz reads; no transform chain here, so it equals the program position): #Previous:
{ "MachineCoordinateState": { "X": -23.958, "Y": -0.0965, "Z": 3.4338 } }
#BeforeBuild:
{
  "Parsing": { "Flags": ["G02"], "I": -23.3261, "J": -1.2062 },
  "ProgramXyz": { "X": -23.3253, "Y": 0.0708, "Z": 3.4338 }
}
#AfterBuild:
{
  "ProgramXyz": { "X": -23.3253, "Y": 0.0708, "Z": 3.4338 },
  "AbsoluteIjkPole": { "I": -23.3261, "J": -1.2062 },
  "MotionState": { "Term": "G02" },
  "MotionEvent": {
    "Form": "McArc",
    "ArcCenter": { "X": -23.3261, "Y": -1.2062, "Z": 3.4338 },
    "IsCcw": false,
    "AdditionalCircleNum": 0,
    "IsIjkAbsolute": true
  }
}
Absolute modal pole (the CC-pole twin): a continuation block writes only J — the I component inherits the previous block's AbsoluteIjkPole, the G03 mode continues via #Previous: MotionState.Term, and the refreshed pole is written back: #Previous:
{
  "MachineCoordinateState": { "X": -25.2297, "Y": 0.0704, "Z": 0 },
  "AbsoluteIjkPole": { "I": -25.2029, "J": -0.9154 },
  "MotionState": { "Term": "G03" }
}
#BeforeBuild:
{
  "Parsing": { "J": -0.9154 },
  "ProgramXyz": { "X": -24.9288, "Y": 0.5929, "Z": 0 }
}
#AfterBuild:
{
  "ProgramXyz": { "X": -24.9288, "Y": 0.5929, "Z": 0 },
  "AbsoluteIjkPole": { "I": -25.2029, "J": -0.9154 },
  "MotionState": { "Term": "G03" },
  "MotionEvent": {
    "Form": "McArc",
    "ArcCenter": { "X": -25.2029, "Y": -0.9154, "Z": 0 },
    "IsCcw": true,
    "AdditionalCircleNum": 0,
    "IsIjkAbsolute": true
  }
}
G91 on an IsIjkAbsolute SUT switches the block back to the ordinary start-to-center offsets (center = begin + (I, J)), ignores the inherited pole and BREAKS the pole chain — the emptied section blocks the ModalCarry copy, so a later absolute block falls back to the arc start (the preArcNcArg.IsIjkAbsolute check of HardNcLine.BuildArcNcArg): #Previous:
{
  "MachineCoordinateState": { "X": 10, "Y": 0, "Z": 0 },
  "AbsoluteIjkPole": { "I": -25.2029, "J": -0.9154 }
}
#BeforeBuild:
{
  "Parsing": { "Flags": ["G02"], "I": 10, "J": 0 },
  "Positioning": { "Term": "G91", "Mode": "Incremental" },
  "ProgramXyz": { "X": 20, "Y": 10, "Z": 0 }
}
#AfterBuild:
{
  "Positioning": { "Term": "G91", "Mode": "Incremental" },
  "ProgramXyz": { "X": 20, "Y": 10, "Z": 0 },
  "AbsoluteIjkPole": {},
  "MotionState": { "Term": "G02" },
  "MotionEvent": {
    "Form": "McArc",
    "ArcCenter": { "X": 20, "Y": 0, "Z": 0 },
    "IsCcw": false,
    "AdditionalCircleNum": 0
  }
}

Constructors

CircularMotionSyntax()

Initializes a new instance with default settings.

public CircularMotionSyntax()

CircularMotionSyntax(XElement)

Initializes a new instance by deserializing from the given XML element.

public CircularMotionSyntax(XElement src)

Parameters

src XElement

Source XML element.

Fields

AbsoluteIjkPoleKey

Root-section key of the modal absolute-center pole (the letters of the last absolute arc, post-inheritance — the SoftNc dual of HardNcLine.ArcNcArg.Ijk). Written by every effective-absolute arc block, emptied by a G91 arc block to break the chain, and carried across intermediate blocks by the brand list's ModalCarrySyntax Logic track. Kept apart from HeidenhainCircleCenterSyntax's Klartext CC section — the two dialect poles never share a key.

public const string AbsoluteIjkPoleKey = "AbsoluteIjkPole"

Field Value

string

Properties

IsIjkAbsolute

When true, I/J/K address the circle center as absolute program coordinates instead of start-to-center offsets, with the modal-pole / G91 semantics described on the class doc. Set by the Heidenhain list (DIN/ISO dialect); every other brand keeps the offset default.

public bool IsIjkAbsolute { get; set; }

Property Value

bool

Name

Syntax kind name (typically the concrete type name).

public string Name { get; }

Property Value

string

XName

XML element name used to register this syntax with XFactory.

public static string XName { get; }

Property Value

string

Methods

Build(LazyLinkedListNode<SyntaxPiece>, List<INcDependency>, NcDiagnosticProgress)

Build syntax arrangement into the syntaxPieceNode in-place.

public void Build(LazyLinkedListNode<SyntaxPiece> syntaxPieceNode, List<INcDependency> ncDependencyList, NcDiagnosticProgress ncDiagnosticProgress)

Parameters

syntaxPieceNode LazyLinkedListNode<SyntaxPiece>
ncDependencyList List<INcDependency>
ncDiagnosticProgress NcDiagnosticProgress

MakeXmlSource(string, string, bool)

Creates an XML representation of the object. This method may also generate additional resources such as related files.

public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)

Parameters

baseDirectory string

The base directory for resolving relative paths

relFile string

The relative file path for the XML source

exhibitionOnly bool

if true, the extended file creation is suppressed.

Returns

XElement

An XML element representing the object's state

Remarks

For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied. The baseDirectory is typically the folder at the nearest configuration file folder. Since the folder can be moving with the configuration file.

Reg(XFactory)

Registers this type's deserializer with the given XFactory (or Default when factory is null). Idempotent.

public static void Reg(XFactory factory = null)

Parameters

factory XFactory