Python gcode.parse and gcode.calc_extents

More
2 years 5 months ago #301417 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.
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.

More
2 years 5 months ago #301418 by cmorley
Have you looked at gremlin/qt_graphics?

Please Log in to join the conversation.

More
2 years 5 months ago #301421 by andypugh
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

Please Log in to join the conversation.

More
2 years 5 months ago #301426 by JT
I have looked st gremlin/qt5_graphics.py and will look closer at it.

Thanks
JT

Please Log in to join the conversation.

More
2 years 5 months ago #301427 by JT
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

Please Log in to join the conversation.

More
2 years 5 months ago #301428 by Aciera
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:
 

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
Powered by Kunena Forum