- Posts: 1108
- Thank you received: 3
Python gcode.parse and gcode.calc_extents
2 years 5 months ago #301417
by JT
Python gcode.parse and gcode.calc_extents was created by JT
I'm trying to figure out what gcode.parse and gcode.calc_extents does and how to use it. I've been grepping and searching for examples but I've not found out the syntax and what is returned.
Not much help there...
With axis running and a terminal open and running python3
grepping I find this example in src/emc/usr_intf/axis/scripts/axis.py:1589:
So what I'm trying to do is display g code on an PyQt QtOpenGLWidget... I think I should be using the glcanon.py from lib/python/rs274... but not sure. I've been thrashing around for a couple of weeks and have not made any progress. If someone has a clue please let me know.
JT
Code:
help(gcode)
calc_extents(...)
Calculate information about extents of gcode
parse(...)
Parse a G-Code file
Not much help there...
With axis running and a terminal open and running python3
Code:
>>> gcode.parse()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: parse() takes at least 2 arguments (0 given)
grepping I find this example in src/emc/usr_intf/axis/scripts/axis.py:1589:
Code:
result, seq = gcode.parse("", canon, "M199 P["+e+"]", "M2")
Code:
>>> gcode.calc_extents()
([9e+99, 9e+99, 9e+99], [-9e+99, -9e+99, -9e+99], [9e+99, 9e+99, 9e+99], [-9e+99, -9e+99, -9e+99])
So what I'm trying to do is display g code on an PyQt QtOpenGLWidget... I think I should be using the glcanon.py from lib/python/rs274... but not sure. I've been thrashing around for a couple of weeks and have not made any progress. If someone has a clue please let me know.
JT
Please Log in to join the conversation.
2 years 5 months ago #301418
by cmorley
Replied by cmorley on topic Python gcode.parse and gcode.calc_extents
Have you looked at gremlin/qt_graphics?
Please Log in to join the conversation.
2 years 5 months ago #301421
by andypugh
Replied by andypugh on topic Python gcode.parse and gcode.calc_extents
By coincidence I found an example of the use of gcode.parse in a post I replied to earlier today:
forum.linuxcnc.org/38-general-linuxcnc-q...code-preview-as-json
forum.linuxcnc.org/38-general-linuxcnc-q...code-preview-as-json
Please Log in to join the conversation.
2 years 5 months ago #301426
by JT
Replied by JT on topic Python gcode.parse and gcode.calc_extents
I have looked st gremlin/qt5_graphics.py and will look closer at it.
Thanks
JT
Thanks
JT
Please Log in to join the conversation.
2 years 5 months ago #301427
by JT
Replied by JT on topic Python gcode.parse and gcode.calc_extents
Actually I just ran gremlin/qt5_graphics.py with Axis running and other than the offsets not being used it plots, just need to figure out how to use it in my GUI.
Thanks
JT
Thanks
JT
Please Log in to join the conversation.
2 years 5 months ago #301428
by Aciera
Replied by Aciera on topic Python gcode.parse and gcode.calc_extents
IIRC .parse will run the gcode and create lists of line segments for 'traverse', 'straight_feed' and 'arc_feed' moves while .calc_extents will then find the minimum and maximum coordinates values from those lists.
This is from lib/python/rs274/glcanon.py:
which calls the pyobject in src/emc/rs274ngc/gcodemodule.cc:
This is from lib/python/rs274/glcanon.py:
Attachment not found
which calls the pyobject in src/emc/rs274ngc/gcodemodule.cc:
Attachment not found
Please Log in to join the conversation.
Time to create page: 0.116 seconds
