View Issue Details

IDProjectCategoryView StatusLast Update
0003035FreeCADBugpublic2017-07-05 17:04
Reportertoshiaki shingu Assigned Tokeithsloan52  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.16 
Fixed in Version0.17 
Summary0003035: exportDXF won't export LWPOLYLINE correctly
Descriptionthe last line of below should decrement indent level.

dxfLibrary.py v1.39 - 2015.09.12

class LwPolyLine(_Entity):
    def __init__(self,points,org_point=[0,0],flag=0,width=None,**common):
        #width = number, or width = list [width_start=None, width_end=None]
        #for 2d-polyline: points = [ [x, y, z, width_start=None, width_end=None, bulge=0 or None], ...]
        _Entity.__init__(self,**common)
        self.points=points
        self.org_point=org_point
        self.flag=flag
        self.width= None # dummy value
        
    def __str__(self):
        result= ' 0\nLWPOLYLINE\n%s ' %(self._common())
        result+=' 8\n%s\n' %self.layer
        result+='100\nAcDbPolyline\n'
        result+=' 90\n%s\n' % len(self.points)
        result+=' 70\n%s\n' %(self.flag)
        result+='%s\n' %_point(self.org_point)
        if self.width!=None:
            result+=' 40\n%s\n 41\n%s\n' %(self.width[0],self.width[1])
        for point in self.points:
            result+='%s\n' %_point(point[0:2])
            if len(point)>4:
                width1, width2 = point[3], point[4]
            if width1!=None: result+=' 40\n%s\n' %width1
            if width2!=None: result+=' 41\n%s\n' %width2
            if len(point)==6:
                bulge = point[5]
                if bulge:
                    result+=' 42\n%s\n' %bulge
                return result
TagsDXF
FreeCAD Information

Relationships

related to 0002267 closedkeithsloan52 File formats failure to open/import CSG 

Activities

Kunda1

2017-05-17 15:41

administrator   ~0009042

Please ask on the forum since the dev version is way ahead of 0.16
Also always post your Help > About FreeCAD > Copy to clipboard whenever you ask for help.

user2853

2017-05-17 16:03

  ~0009043

Last edited: 2017-05-17 16:23

This has to do with @Yorik legacy python dxf importer. See here: https://github.com/yorikvanhavre/Draft-dxf-importer/blob/master/dxfLibrary.py#L430-L459

yorik

2017-05-25 13:56

administrator   ~0009133

I don't understand what is the issue here?
As far as I can see the code block above only has the last line changed? Why is it so? We want to return a result even if the point has no bulge value...

user2853

2017-05-25 22:20

  ~0009142

Last edited: 2017-05-25 22:22

@toshiaki shingu
Can you provide a file that fails with the existing code and succeeds with the indent reduced?

toshiaki shingu

2017-05-29 14:34

reporter   ~0009186

Attached polyline.dxf is a rectanglar exported by importDXF.export(object, file, lwPoly=false).

lwpolyline1.dxf is exported by importDXF.export(object, file, lwPoly=True).

lwpolylin2.dxf is exported by importDXF.export(object, file, lwPoly=True) with patched dxfLibrary.py.

Best wishes,
dxfLibrary.py.patch (671 bytes)   
*** dxfLibrary.py.orig	Sun May 28 10:37:13 2017
--- dxfLibrary.py	Sun May 28 11:17:42 2017
***************
*** 443,449 ****
  		result+='100\nAcDbPolyline\n'
  		result+=' 90\n%s\n' % len(self.points)
  		result+=' 70\n%s\n' %(self.flag)
- 		result+='%s\n' %_point(self.org_point)
  		if self.width!=None:
  			result+=' 40\n%s\n 41\n%s\n' %(self.width[0],self.width[1])
  		for point in self.points:
--- 443,448 ----
***************
*** 456,462 ****
  				bulge = point[5]
  				if bulge: 
  					result+=' 42\n%s\n' %bulge
! 			return result
  
  
  
--- 455,461 ----
  				bulge = point[5]
  				if bulge: 
  					result+=' 42\n%s\n' %bulge
! 		return result
  
  
  
dxfLibrary.py.patch (671 bytes)   
polyline.dxf (1,116 bytes)
lwpolyline1.dxf (916 bytes)
lwpolyline2.dxf (959 bytes)

Kunda1

2017-06-15 12:18

administrator   ~0009381

@sgrogan1 looks like OP replied

keithsloan52

2017-06-15 15:39

developer   ~0009387

Last edited: 2017-06-15 16:25

If somebody is looking to fix this problem maybe they could also look at 0002267 which I suspect is similar. Least it involves incorrect DXF file with lwpolyline

Kunda1

2017-06-15 16:28

administrator   ~0009388

Linked 0002267 to this ticket

user2853

2017-06-15 21:01

  ~0009392

Last edited: 2017-06-15 21:32

I had only noticed before, the indent change in the second part of the patch. I didn't notice the line deletion in the first part of the patch. I won't have time to test until the weekend, no promises there either. Definitely 0002267 looks related.
Anyway @yorik will need to look at this. If the patch is accepted it needs to be applied on his dxf branch. Then it will propagate to the FreeCAD-addons repo.

Tracker Admin edit: FTFY ;) FYI To ref another ticket just prefix ticket number with: #

keithsloan52

2017-06-21 15:07

developer   ~0009484

Last edited: 2017-06-21 15:09

I corrected the dxf library and made a Pull request see https://github.com/yorikvanhavre/Draft-dxf-importer

@yorik @sgrogan1

Have tested for issue 0002267 which also suffers from the same bug.
With the corrected code I can now import the plate csg file okay.

The intermediate DXF file is now correct

Kunda1

2017-06-25 15:49

administrator   ~0009527

@yorik & @sgrogan1 can you test Keith's PR to confirm the fix?

yorik

2017-06-26 14:06

administrator   ~0009542

Keith's PR is merged. Seems to work fine!

Kunda1

2017-06-26 15:40

administrator   ~0009546

@yorik great! Is it merged in to master? When it is please reference the commits to this ticket 0003035 and to 0002267 and close said ticket. Thanks!

keithsloan52

2017-06-26 17:09

developer   ~0009548

Not sure it needs to be merged into Master the library is dynamically loaded by FreeCAD. i.e The fact that the library is fixed should be enough.

Kunda1

2017-06-26 19:14

administrator   ~0009550

Dynamically loaded from an upstream source?

keithsloan52

2017-06-26 20:25

developer   ~0009551

Dynamically loaded by FreeCAD

Kunda1

2017-06-26 21:40

administrator   ~0009552

Marking as fixed.
FYI Users need to set the preference for FreeCAD to load the dxf library to pick up latest version.
Thanks Keith!

Kunda1

2017-07-05 17:04

administrator   ~0009671

Closing

Issue History

Date Modified Username Field Change
2017-05-17 15:25 toshiaki shingu New Issue
2017-05-17 15:41 Kunda1 Note Added: 0009042
2017-05-17 16:03 user2853 Note Added: 0009043
2017-05-17 16:23 user2853 Note Edited: 0009043
2017-05-25 13:56 yorik Note Added: 0009133
2017-05-25 15:28 Kunda1 Status new => feedback
2017-05-25 22:20 user2853 Note Added: 0009142
2017-05-25 22:21 user2853 Note Edited: 0009142
2017-05-25 22:22 user2853 Note Edited: 0009142
2017-05-29 14:34 toshiaki shingu File Added: dxfLibrary.py.patch
2017-05-29 14:34 toshiaki shingu File Added: polyline.dxf
2017-05-29 14:34 toshiaki shingu File Added: lwpolyline1.dxf
2017-05-29 14:34 toshiaki shingu File Added: lwpolyline2.dxf
2017-05-29 14:34 toshiaki shingu Note Added: 0009186
2017-05-29 14:34 toshiaki shingu Status feedback => new
2017-06-15 12:18 Kunda1 Note Added: 0009381
2017-06-15 12:19 Kunda1 Tag Attached: DXF
2017-06-15 15:39 keithsloan52 Note Added: 0009387
2017-06-15 16:25 Kunda1 Note Edited: 0009387
2017-06-15 16:26 Kunda1 Relationship added related to 0002267
2017-06-15 16:28 Kunda1 Note Added: 0009388
2017-06-15 21:01 user2853 Note Added: 0009392
2017-06-15 21:03 user2853 Note Edited: 0009392
2017-06-15 21:04 user2853 Note Edited: 0009392
2017-06-15 21:06 user2853 Note Edited: 0009392
2017-06-15 21:07 user2853 Note Edited: 0009392
2017-06-15 21:09 user2853 Note Edited: 0009392
2017-06-15 21:10 user2853 Note Edited: 0009392
2017-06-15 21:10 user2853 Note Edited: 0009392
2017-06-15 21:32 Kunda1 Note Edited: 0009392
2017-06-21 15:07 keithsloan52 Note Added: 0009484
2017-06-21 15:09 keithsloan52 Note Edited: 0009484
2017-06-21 15:09 keithsloan52 Note Edited: 0009484
2017-06-25 15:49 Kunda1 Note Added: 0009527
2017-06-26 14:06 yorik Note Added: 0009542
2017-06-26 15:40 Kunda1 Note Added: 0009546
2017-06-26 17:09 keithsloan52 Note Added: 0009548
2017-06-26 19:14 Kunda1 Note Added: 0009550
2017-06-26 20:25 keithsloan52 Note Added: 0009551
2017-06-26 21:40 Kunda1 Assigned To => keithsloan52
2017-06-26 21:40 Kunda1 Status new => resolved
2017-06-26 21:40 Kunda1 Resolution open => fixed
2017-06-26 21:40 Kunda1 Fixed in Version => 0.17
2017-06-26 21:40 Kunda1 Note Added: 0009552
2017-07-05 17:04 Kunda1 Note Added: 0009671
2017-07-05 17:04 Kunda1 Status resolved => closed