Python gcode.parse and gcode.calc_extents

  • JT
  • JT's Avatar Topic Author
  • Away
  • Administrator
  • Administrator
More
25 May 2024 16:14 - 25 May 2024 16:16 #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.
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
>>> 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: 
result, seq = gcode.parse("", canon, "M199 P["+e+"]", "M2")

>>> 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
Last edit: 25 May 2024 16:16 by JT.

Please Log in or Create an account to join the conversation.

More
25 May 2024 16:41 #301418 by cmorley
Have you looked at gremlin/qt_graphics?
The following user(s) said Thank You: JT

Please Log in or Create an account to join the conversation.

More
25 May 2024 17:30 #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
The following user(s) said Thank You: JT

Please Log in or Create an account to join the conversation.

  • JT
  • JT's Avatar Topic Author
  • Away
  • Administrator
  • Administrator
More
25 May 2024 18:08 #301426 by JT
I have looked st gremlin/qt5_graphics.py and will look closer at it.

Thanks
JT

Please Log in or Create an account to join the conversation.

  • JT
  • JT's Avatar Topic Author
  • Away
  • Administrator
  • Administrator
More
25 May 2024 18:21 #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 or Create an account to join the conversation.

More
25 May 2024 18:21 #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:
 

which calls the pyobject in src/emc/rs274ngc/gcodemodule.cc:
 
 
Attachments:
The following user(s) said Thank You: JT

Please Log in or Create an account to join the conversation.

Time to create page: 0.107 seconds
Powered by Kunena Forum