@@ -168,6 +168,7 @@ public void ParseGCodeFile()
168168
169169 Vector3 position = new Vector3 ( 0 , 0 , 0 ) ;
170170 float angle = 0f ;
171+ bool absolutePositioning = true ;
171172
172173 GCodeCommandList gCodeCommands = new GCodeCommandList ( File . ReadAllLines ( _filename ) ) ;
173174
@@ -257,14 +258,22 @@ void UpdateLineSequence(LinearInterpolationCmd linearCmd)
257258 {
258259 _currentVB . LineSequence3D = new VectorBlock . Types . LineSequence3D ( ) ;
259260 }
260- _currentVB . LineSequence3D . Points . Add ( linearCmd . xPosition ?? position . X ) ;
261- _currentVB . LineSequence3D . Points . Add ( linearCmd . yPosition ?? position . Y ) ;
262- _currentVB . LineSequence3D . Points . Add ( linearCmd . zPosition ?? position . Z ) ;
261+ _currentVB . LineSequence3D . Points . Add ( absolutePositioning
262+ ? ( linearCmd . xPosition ?? position . X ) // Use absolute x-positioning
263+ : ( position . X + ( linearCmd . xPosition ?? 0 ) ) ) ; // Use relative xpositioning
264+ _currentVB . LineSequence3D . Points . Add ( absolutePositioning
265+ ? ( linearCmd . yPosition ?? position . Y ) // Use absolute y-positioning
266+ : ( position . Y + ( linearCmd . yPosition ?? 0 ) ) ) ; // Use relative y-positioning
267+ _currentVB . LineSequence3D . Points . Add ( absolutePositioning
268+ ? ( linearCmd . zPosition ?? position . Z ) // Use absolute y-positioning
269+ : ( position . Z + ( linearCmd . zPosition ?? 0 ) ) ) ; // Use relative y-positioning
263270 }
264271
265272 void UpdateArc ( CircularInterpolationCmd circularCmd )
266273 {
267- Vector3 targetPosition = new Vector3 ( circularCmd . xPosition ?? position . X , circularCmd . yPosition ?? position . Y , circularCmd . zPosition ?? position . Z ) ;
274+ Vector3 targetPosition = new Vector3 ( absolutePositioning ? ( circularCmd . xPosition ?? position . X ) : ( position . X + ( circularCmd . xPosition ?? 0 ) ) ,
275+ absolutePositioning ? ( circularCmd . yPosition ?? position . Y ) : ( position . Y + ( circularCmd . yPosition ?? 0 ) ) ,
276+ absolutePositioning ? ( circularCmd . zPosition ?? position . Z ) : ( position . Z + ( circularCmd . zPosition ?? 0 ) ) ) ;
268277 Vector3 center = new Vector3 ( position . X + circularCmd . xCenterRel ?? 0 , position . Y + circularCmd . yCenterRel ?? 0 , position . Z ) ;
269278
270279 Vector3 vectorCP = position - center ; // Vector from center to start position
@@ -329,8 +338,10 @@ void UpdateSpeed(bool isOperation, float? newSpeed)
329338
330339 void ProcessPauseCmd ( PauseCommand pauseCmd )
331340 {
341+ NewVectorBlock ( ) ;
332342 _currentVB . ExposurePause = new VectorBlock . Types . ExposurePause ( ) ;
333343 _currentVB . ExposurePause . PauseInUs = ( ulong ) pauseCmd . duration * 1000 ;
344+ NewVectorBlock ( ) ;
334345 }
335346
336347 void ProcessToolChangeCmd ( ToolChangeCommand toolChangeCmd )
@@ -345,7 +356,17 @@ void ProcessMonitoringCmd(MonitoringCommand monitoringCmd)
345356
346357 void ProcessProgramLogicsCmd ( ProgramLogicsCommand programLogicsCmd )
347358 {
359+ switch ( programLogicsCmd )
360+ {
361+ case PositioningToggleCommand toggleCmd :
362+ TogglePositioning ( toggleCmd ) ;
363+ break ;
364+ }
348365
366+ void TogglePositioning ( PositioningToggleCommand toggleCmd )
367+ {
368+ absolutePositioning = toggleCmd . isAbsolute ;
369+ }
349370 }
350371
351372 void ProcessMiscCmd ( MiscCommand miscCmd )
0 commit comments