1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
From: =?utf-8?q?Christian_Kohl=C3=B6ffel?=
<christian.kohloeffel@googlemail.com>
Date: Fri, 16 Mar 2018 20:22:38 +0100
Subject: fix dxf LWPolyLine import
This commit is cherry-picked from upstream's commit 2bab0a20.
Forwarded: https://sourceforge.net/p/dxf2gcode/sourcecode/ci/2bab0a200cd1643c54b6fdf5b54c3e84aee59946/
---
dxf2gcode/dxfimport/geoent_lwpolyline.py | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/dxf2gcode/dxfimport/geoent_lwpolyline.py b/dxf2gcode/dxfimport/geoent_lwpolyline.py
index 67fb546..0fe9c47 100644
--- a/dxf2gcode/dxfimport/geoent_lwpolyline.py
+++ b/dxf2gcode/dxfimport/geoent_lwpolyline.py
@@ -28,11 +28,15 @@ from __future__ import division
from __future__ import absolute_import
from __future__ import division
+import logging
+
from dxf2gcode.core.point import Point
from dxf2gcode.core.arcgeo import ArcGeo
from dxf2gcode.core.linegeo import LineGeo
from dxf2gcode.dxfimport.classes import PointsClass, ContourClass
+logger = logging.getLogger("DXFImport.GeoentLWPolyline")
+
class GeoentLwPolyline(object):
def __init__(self, Nr=0, caller=None):
@@ -163,7 +167,7 @@ class GeoentLwPolyline(object):
s_bulge = lp.index_code(42, s + 1, e_nxt_b)
- # print('stemp: %s, e: %s, next 10: %s' %(s_temp,e,lp.index_code(10,s+1,e)))
+ #logger.debug('stemp: %s, e: %s, next 10: %s' %(s_bulge,e,lp.index_code(10,s+1,e)))
if s_bulge is not None:
bulge = float(lp.line_pair[s_bulge].value)
s_nxt_x = s_nxt_x
@@ -173,12 +177,12 @@ class GeoentLwPolyline(object):
# Assign the geometries for the Polyline
if Ps is not None:
- if next_bulge == 0:
+ if bulge == 0:
self.geo.append(LineGeo(Ps=Ps, Pe=Pe))
else:
# self.geo.append(LineGeo(Ps=Ps,Pe=Pe))
# print bulge
- self.geo.append(self.bulge2arc(Ps, Pe, next_bulge))
+ self.geo.append(self.bulge2arc(Ps, Pe, bulge))
# L�nge drauf rechnen wenns eine Geometrie ist
# Wenns Ldnge count on it is a geometry ???
@@ -189,13 +193,18 @@ class GeoentLwPolyline(object):
Ps = Pe
if LWPLClosed == 1 or LWPLClosed == 129:
- # print("sollten �bereinstimmen: %s, %s" %(Ps,Pe))
- if next_bulge:
+ #logger.debug("sollten �bereinstimmen: %s, %s" %(Ps,Pe))
+ #logger.debug(self.geo)
+ if next_bulge and len(self.geo)>0:
self.geo.append(self.bulge2arc(Ps, self.geo[0].Ps, next_bulge))
- else:
+ self.length += self.geo[-1].length
+ elif len(self.geo)>0:
self.geo.append(LineGeo(Ps=Ps, Pe=self.geo[0].Ps))
+ self.length += self.geo[-1].length
+ else:
+ pass
+
- self.length += self.geo[-1].length
# New starting value for the next geometry
caller.start = e
|