Total lines in a GCode file
- scsmith1451
-
Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 82
- Thank you received: 3
23 Jun 2026 13:22 #347268
by scsmith1451
Total lines in a GCode file was created by scsmith1451
Examining the linuxcnc.stat() module I see that there is "current_line" method. Is there a way to get the total number of lines in a loaded gcode file to drive a progress meter?
Please Log in or Create an account to join the conversation.
- MikkelRS
-
- Offline
- New Member
-
Less
More
- Posts: 13
- Thank you received: 4
23 Jun 2026 14:38 #347270
by MikkelRS
Replied by MikkelRS on topic Total lines in a GCode file
I dont have an answer, but i know its possible - there are interfaces with progress bars.
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
Less
More
- Posts: 4722
- Thank you received: 2115
23 Jun 2026 15:23 #347272
by Aciera
Replied by Aciera on topic Total lines in a GCode file
Gmoccapy simply counts the lines of the loaded file:
def on_hal_status_file_loaded(self, widget, filename):
widgetlist = ["btn_use_current" ]
# this test is only necessary, because of remap and toolchange, it will emit a file loaded signal
if filename:
fileobject = open(filename, 'r')
lines = fileobject.readlines()
fileobject.close()
self.halcomp["program.length"] = len(lines)
if len(filename) > 70:
filename = filename[0:10] + "..." + filename[len(filename) - 50:len(filename)]
self.widgets.lbl_program.set_text(filename)
self._sensitize_widgets(widgetlist, True)
else:
self.halcomp["program.length"] = 0
self._sensitize_widgets(widgetlist, False)
self.widgets.lbl_program.set_text(_("No file loaded"))Please Log in or Create an account to join the conversation.
- scsmith1451
-
Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 82
- Thank you received: 3
23 Jun 2026 16:50 #347276
by scsmith1451
Replied by scsmith1451 on topic Total lines in a GCode file
This was my thinking to get the program length if it was not being computed.
Is there a way of accessing "program.length" to set a global # parameter, say #1100 (#1100 = halcomp["program.length"] or is there a way to access halcomp["program.length"] inside of gCode?
Or better yet, is program progress being computed by gmoccapy which can be connected to an analog output, say motion.analog-out-01? This would be preferred since no additional lines need to be added a gcode file to track progress., just a HAL connection to the display widget.
Is there a way of accessing "program.length" to set a global # parameter, say #1100 (#1100 = halcomp["program.length"] or is there a way to access halcomp["program.length"] inside of gCode?
Or better yet, is program progress being computed by gmoccapy which can be connected to an analog output, say motion.analog-out-01? This would be preferred since no additional lines need to be added a gcode file to track progress., just a HAL connection to the display widget.
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
Less
More
- Posts: 4722
- Thank you received: 2115
23 Jun 2026 17:15 - 23 Jun 2026 17:21 #347277
by Aciera
Replied by Aciera on topic Total lines in a GCode file
Attachments:
Last edit: 23 Jun 2026 17:21 by Aciera.
Please Log in or Create an account to join the conversation.
Time to create page: 0.123 seconds