Menu

SourceCode Merge Request #19: Slightly reworked submit of lately reverted patch (merged)

Merging...

Merged

Something went wrong. Please, merge manually

Checking if merge is possible...

Something went wrong. Please, merge manually

Andrey Zabolotnyi wants to merge 5 commits from /u/andyz/dxf2gcode/ to develop, 2020-02-04

I noted one of my patches were reverted.
I checked and didn't found why.
If I re-apply the patch on upstream develop branch, all tests would pass except "top.dxf", which crashes dxf2gcode. I fixed that bug as well. Now (with the proposed patch) all tests pass:

Ran 73 tests in 1477.453s

OK

I'll explain what the patch fixes (how to reproduce the bug and how to check my patch fixes it).

  1. Load ../dxf/1997.DXF. Create the StMoves (e.g. Ctrl+O) into the current develop branch (without my patch).
  2. Now select the outline of second '9' and press RMB -> Set nearest point.
  3. You will see the lead-in/out shape points will change, but the StMove's will remain as they were.
  4. Now if you export G-Code and load it in, say, Camotics, you will see that the digits are carved all wrong!
  5. Apply my patch and repeat same operations. You will note that a) After "Set nearest point" the StMove's will update correctly, and the resulting G-Code will be correct now.
Commit Date  
[4da0a9] (upstream-fix-gcode-export) by Andrey Zabolotnyi Andrey Zabolotnyi

Fixed a bug in latest changes that manifests itself only with the 2D driver.
The reason was that the update() member function name is used by Qt objects, so I renamed it to updateShape().

2020-02-03 20:18:38 Tree
[a632b5] by Andrey Zabolotnyi Andrey Zabolotnyi

Now after "set nearest point" operation the start moves will be correctly updated on the drawing

2020-02-01 22:51:52 Tree
[086590] by Andrey Zabolotnyi Andrey Zabolotnyi

Fixed a old nasty bug that would cause broken G-code export after invoking Shape.setNearestStPoint()

2020-02-01 22:20:20 Tree
[898e3f] by Andrey Zabolotnyi Andrey Zabolotnyi

Fix program crash when loading dxf/top.dxf

2020-02-01 21:31:30 Tree
[706ed1] by Andrey Zabolotnyi Andrey Zabolotnyi

Replaced __str__ with __repr__ which is similar, but allows printing lists of objects as well

2020-02-01 21:30:34 Tree

Discussion

  • Damian Wrobel

    Damian Wrobel - 2020-02-03

    Andrey,

    I noted one of my patches were reverted.
    I checked and didn't found why.

    You may find the explanation of the revert in the commit message, see below:

    commit 19c236e50f39314496a31bcb0467404a070ffd7a
    Author: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
    Date:   Fri Oct 11 23:13:20 2019 +0200
    
        Revert "* Fixed a old nasty bug that would cause broken G-code export after invoking Shape.setNearestStPoint()"
    
        This reverts commit de18ef31e2338e8df5c0d00e225b7c859407bfd5.
    
        Reverted as it broke 69 tests!
    
        Broken test reported (depending on the platform):
          - Linux: Error exporting shapes: list index out of range
        or
          - Windows: AttributeError: 'StMoveGUI' object has no attribute 'geos'
    

    As you could see it broke almost all of tests at that time.

    If I re-apply the patch on upstream develop branch, all tests would pass except "top.dxf", which >crashes dxf2gcode. I fixed that bug as well. Now (with the proposed patch) all tests pass:

    Ran 73 tests in 1477.453s

    OK

    Unfortunately when I try to test your changes I still see errors like below:

    $ ./dxf2gcode_test.py
    
    
    Executing ['/usr/bin/python3', './dxf2gcode.py', '--quiet', '-e', './1.dxf', '../dxf/1.dxf']
    QSocketNotifier: Can only be used with threads started with QThread
    Creating configuration window
    Creating configuration window
    Loading file: ../dxf/1.dxf
    Reading DXF Structure
    Reading Block *MODEL_SPACE; Nr: 0
    Reading Block *PAPER_SPACE; Nr: 1
    Creating Contours of Block Nr: 0
    Creating Contours of Block Nr: 1
    Creating Contours of Entities
    Loaded layers: 1
    Loaded blocks: 2
    Block 0 includes 0 Geometries, reduced to 0 Contours, used layers: []
    Block 1 includes 0 Geometries, reduced to 0 Contours, used layers: []
    Loaded 9 entity geometries; reduced to 2 contours; used layers: [0]; number of inserts 0
    Drawing units: inches
    Traceback (most recent call last):
      File "./dxf2gcode.py", line 1214, in <module>
        window.load()
      File "./dxf2gcode.py", line 892, in load
        self.plot()
      File "./dxf2gcode.py", line 905, in plot
        self.canvas_scene.plotAll(self.shapes)
      File "/home/sw/projects/dxf2gcode/dxf2gcode-sourcecode/source/dxf2gcode/gui/canvas2d.py", line 294, in plotAll
        self.paint_shape(shape)
      File "/home/sw/projects/dxf2gcode/dxf2gcode-sourcecode/source/dxf2gcode/gui/canvas2d.py", line 328, in paint_shape
        shape.stmove = self.createstmove(shape)
      File "/home/sw/projects/dxf2gcode/dxf2gcode-sourcecode/source/dxf2gcode/gui/canvas2d.py", line 384, in createstmove
        stmove = StMoveGUI(shape)
      File "/home/sw/projects/dxf2gcode/dxf2gcode-sourcecode/source/dxf2gcode/gui/canvas2d.py", line 638, in __init__
        self.make_papath()
      File "/home/sw/projects/dxf2gcode/dxf2gcode-sourcecode/source/dxf2gcode/gui/canvas2d.py", line 653, in make_papath
        if len(self.geos):
    AttributeError: 'StMoveGUI' object has no attribute 'geos'
    F
    

    The final test result is:

    Ran 76 tests in 296.940s
    
    FAILED (failures=73)
    

    I'm using fedora 31 with:

    $ rpm -qv python3
    python3-3.7.6-1.fc31.x86_64
    
    $ rpm -qv python3-qt5-base
    python3-qt5-base-5.13.2-3.fc31.x86_64
    

    Please also notice the difference in the number of tests. You mentioned 73 while on the develop branch (at the time of writing) we have currently 76 tests available . It looks like you're not testing against the latest version of the develop branch.

     
  • Andrey Zabolotnyi

    hmm... If I check-out a clean repository:

    # git clone ssh://andyz@git.code.sf.net/p/dxf2gcode/sourcecode dxf2gcode-sourcecode
    # cd dxf2gcode-sourcecode
    # git checkout develop
    # find . -name '*.dxf' -o -name '*.DXF' | wc -l
    73
    

    perhaps, you have 3 uncommited dxf files...

    I'm on Fedora27 with
    python3-3.6.6-1.fc27.x86_64
    python3-qt5-base-5.9.1-3.fc27.x86_64
    which shouldn't make difference...

    Now I apply the proposed patch:

    # git fetch ssh://andyz@git.code.sf.net/u/andyz/dxf2gcode upstream-fix-gcode-export
    # git merge a632b51fbdbd0b720a181462b111867af1a6021d
    Updating cd19f24..a632b51
    ...
    

    The run the test on 1.dxf, as in your log above:

    # ./dxf2gcode.py -q -e ./1.dxf ../dxf/1.dxf
    Creating configuration window
    OpenGL_accelerate module loaded
    Using accelerated ArrayDatatype
    Creating configuration window
    Loading file: ../dxf/1.dxf
    Reading DXF Structure
    Reading Block *MODEL_SPACE; Nr: 0
    Reading Block *PAPER_SPACE; Nr: 1
    Creating Contours of Block Nr: 0
    Creating Contours of Block Nr: 1
    Creating Contours of Entities
    Loaded layers: 1
    Loaded blocks: 2
    Block 0 includes 0 Geometries, reduced to 0 Contours, used layers: []
    Block 1 includes 0 Geometries, reduced to 0 Contours, used layers: []
    Loaded 9 entity geometries; reduced to 2 contours; used layers: [0]; number of inserts 0
    Drawing units: inches
    Export to FILE was successful
    

    dxf2gcode_test.py also runs almost ok:

    ======================================================================
    FAIL: test_DRAAK.dxf (__main__.TestDXF2Gcode)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "./dxf2gcode_test.py", line 49, in test
        self.assertEqual(rv, 0, description)
    AssertionError: 1 != 0 : DRAAK.dxf
    
    ----------------------------------------------------------------------
    Ran 73 tests in 1322.141s
    
    FAILED (failures=1)
    

    the problem with DRAAK.dxf is some other problem, never seen it before:

      File "/home/zap/src/cnc/dxf2gcode-devel/source/dxf2gcode/dxfimport/spline_convert.py", line 224, in fit_triac_by_inc_biarc
        u = (X0 + X1 * t) / (Y0 + Y1 * t)
    ZeroDivisionError: float division by zero
    

    Could you try with a clean repository like I did above?

     
  • Andrey Zabolotnyi

    I found what's wrong. I'm using the 3D driver and you're using the 2D one :)
    After I changed the option, I get the crash too.
    The reason is that I added StMove::update method, and StMoveGUI in 2D driver uses update() method as well, so they conflicted.
    Latest fix should fix it all.

     
  • Damian Wrobel

    Damian Wrobel - 2020-02-03

    Latest fix should fix it all.

    Ran 73 tests in 479.247s
    
    OK
    

    Indeed, great!

    I can confirm no regressions on 4da0a94e082edca5e9b23c5cc2bef63e44e2dce1.

     
  • chrisko

    chrisko - 2020-02-04
    • Status: open --> merged
     
  • chrisko

    chrisko - 2020-02-04

    Thank you all for this support ...

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.