I rebuilt the project, and got it to work nowCentroid_Jacob wrote: ↑Mon Dec 09, 2024 12:18 pm I copied your GetSystemVariable C# code into my project and ran it without issue here. Tested with Offline 5.22 and Regular 5.22 and I always see the value as long as the Pipe is not broken. Did the same after converting to VB, no issues, always returns the value set by MDI as long as pipe is unbroken.
What version of CNC12 are you working with?

However I am curious about the behaviour I am seeing:
When I check the SystemVariable via the API, it gets immediately set to the last instance of the variable when the job starts. I was expecting it to output "1" after it starts the Face operation, and only output "2" after it gets to the end. But in my case, it outputs "2" as soon as I start the job.
It seems like CNC12 is evaluating the entire file, and sets the variable to the last instance upon starting.
Am I inserting the variables wrong in the file to cause this?
Code: Select all
; ICN_PATH = C:\intercon\API_test_file.icn
; --- Header ---
N0001 ; CNC code generated by Intercon v5.22
; Description: API Test File
; Programmer: Johannes
; Date: 08-Dec-2024
M25 G49 ; Goto Z home, cancel tool length offset
G17 G40 ; Setup for XY plane, no cutter comp
G21 ; millimeter measurements
G80 ; Cancel canned cycles
G90 ; absolute positioning
G98 ; canned cycle initial point return
; --- Face ---
#29110 = 1
N0002 G0 X0.0 Y0.0 Z2.54
G1 X0.0 Y0.0 Z-7.54 F1155.0
X30.0 Y0.0 Z0.0 F11700.0
X0.0 Y16.0 Z0.0
X30.0 Y0.0 Z0.0
X0.0 Y12.0 Z0.0
X-30.0 Y0.0 Z0.0
G0 G90 X0.0 Y30.0 Z2.54
#29110 = 2
; --- End of Program ---
N0003 G49 H0 M25
G40 ; Cutter Comp Off
M5 ; Spindle Off
M9 ; Coolant Off
G80 ; Cancel canned cycles
M30 ; End of program