HPGL Postprocessor yields wrong syntax

Issue #346 resolved
Robert created an issue

The HPGL Postprocessor yields wrong syntax. Within the statement for absolute positioning [PAx,y], x and y must be integers between -32767 and 32768, each representing a multiple of 0.025mm. Current code yields Floats in Millimeters!

→ In hpgl.py, line 16, the format should be changed to yield signed integer not float.

→ In hpgl.py, line 52-53 the conversion does not work, because the value is first divided by 0.025 and rounded, then multiplied with 0.025 again, the multiplication must be omitted

The bug is within the current beta version.

Comments (22)

  1. Marius Stanciu

    Thanks for the report. This is not something that I use so I rely on user reports like yours to make it work reliably.

    BTW, if you can, please test the new HPGL2 import (only absolute coordinates and only linear, arc and circles supported for now).

  2. Robert reporter

    Hi, thanks. I did the changes here locally, and code got valid, but preview was scaled improperly. Could you fix this, too?

  3. Marius Stanciu

    I’m sorry but I don’t understand what are you trying to say. Which preview? What changes? And what are you trying to do?

  4. Robert reporter

    Oh, I am sorry for being not precise enough. To test, I deleted the wrong term “* 25 / 1000” in both, line 52 and 53 of hpgl.py, which yields the x and y values being multiples of 0.025 now as intended. But now, the preview of the CNC Job is scaled uncorrectly, it is 1/0.025 = 40 times too large. I attached a screenshot of this behavior. Notice the small outline of the original gerber and the geometry in the bottom left corner of the plot area.

    Thanks

  5. Marius Stanciu

    The problem is that FlatCAM was made to work with GCode. And that is either in INCH or in MM. I will see what can be done to hack this.

  6. Robert reporter

    Okay, thank you so much. To be fully compliant with HPGL, x and y should be represented as integers in the CNC code. That is for example, in your screenshot, line 12 should read as PA718,594; and not PA718.0000,594.0000; This holds for the other PA - statements, too.

  7. Marius Stanciu

    Don’t worry, there is no need for donation. There is a balance in Universe (even the laws of physics say that), just help someone if he/she asks for help and all is OK.

  8. Marius Stanciu

    Hi Robert,

    Can you try the latest release 8.991 and turn on the Gray icons and then post a screenshot here? I am curious if they work better in a dark environment like the one you use.

    Thanks,
    Marius
    (Happy Holidays!)

  9. Robert reporter

    Hi Marius,

    I am sorry, but I can test this in a week or so, because I am on holidays and do not have my computer with me.

    Happy new year, Robert

  10. Robert reporter

    Hi,

    i cloned latest Beta branch and turned on gray icons. See the screenshot attached. Note, that the theme switch does not have any effect for me using OS X dark theme. Interestingly, ifI build an app using py2applet, the theme becomes light, but the toggle switch does not work at all.

    Here is the latest beta started using the command

    python3 flatcam.py
    

    See, the theme toggle does not change the theme, even if the app is restarted.

    Next is a screenshot of the same app but packed into an app using py2app:

    py2applet --make-setup flatCAM.py
    python3 setup.py py2app -A  
    cd dist
    open .
    

    (Ref.: https://gist.github.com/natevw/3e6fc929aff358b38c0a#gistcomment-3111878)

    Note, again the theme toggle does not change the theme, but it is light now. Why? I don’t know.

    Additionally, whenever I press the apply theme button, flatcam instantly crashes and refuses to reopen until I restart my computer. See the following log:

    Last login: Thu Jan  2 18:58:40 on ttys000
    Robert@Roberts-iMac ~ % cd flatcam                       
    Robert@Roberts-iMac flatcam % python3 flatcam.py               
    Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created.
    [INFO][MainThread] FlatCAM Starting...
    [DEBUG][MainThread] Application path is /Users/Robert/flatcam
    [DEBUG][MainThread] Started in /Users/Robert/flatcam
    [DEBUG][MainThread] FlatCAM defaults loaded from: current_defaults
    Traceback (most recent call last):
      File "/Users/Robert/flatcam/FlatCAMApp.py", line 12379, in my_loop
        listener = Listener(*address)
      File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/connection.py", line 438, in __init__
        self._listener = SocketListener(address, family, backlog)
      File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/connection.py", line 581, in __init__
        self._socket.bind(address)
    OSError: [Errno 48] Address already in use
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/Robert/flatcam/FlatCAMApp.py", line 12403, in run
        self.my_loop(self.address)
      File "/Users/Robert/flatcam/FlatCAMApp.py", line 12384, in my_loop
        conn = Client(*address)
      File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/connection.py", line 492, in Client
        c = SocketClient(address)
      File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/connection.py", line 619, in SocketClient
        s.connect(address)
    ConnectionRefusedError: [Errno 61] Connection refused
    zsh: abort      python3 flatcam.py
    Robert@Roberts-iMac flatcam % 
    

    Happy new year, Robert

  11. Marius Stanciu

    Hi Robert,

    The theme change is made to work only for the Plot Area. Nothing else is changed because it is too much work to style every GUI item.
    Regarding the error from the end, it’s a change that I’ve made recently but I guess that while it works for Windows/Linux, not so for OSX so I will have to make the feature unavailable for OSX.

    The icons I guess are kind of alright, isn’t it?

    A New and Prosperous Year,,
    Marius

  12. Log in to comment