View Issue Details

IDProjectCategoryView StatusLast Update
0000482FreeCADBugpublic2011-11-17 14:34
Reportercstrachan1 Assigned Toyorik  
PrioritynormalSeveritytrivialReproducibilityalways
Status closedResolutionfixed 
Product Version0.11 
Fixed in Version0.12 
Summary0000482: Exporting to DXF causes zero vector length exception
DescriptionTo reproduce:
Open attached file DXFTest
Select Fusion object
Select export from file menu
enter a filename ending in .dxf
exception occurs:

colin@cs-sis-gcs-laptop:~/Downloads/free-cad$ bin/FreeCAD
FreeCAD 0.12, Libs: 0.12R4851
© Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2011
  ##### #### ### ####
  # # # # # #
  # ## #### #### # # # # #
  #### # # # # # # # ##### # #
  # # #### #### # # # # #
  # # # # # # # # # ## ## ##
  # # #### #### ### # # #### ## ## ##

processing Fusion
Exception (Fri Nov 11 16:09:39 2011): Cannot normalize null vector
Stack Trace: Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "/home/colin/Downloads/free-cad/Mod/Draft/importDXF.py", line 1135, in export
    block = getBlock(ob)
  File "/home/colin/Downloads/free-cad/Mod/Draft/importDXF.py", line 1037, in getBlock
    writeShape(obj,block)
  File "/home/colin/Downloads/free-cad/Mod/Draft/importDXF.py", line 1052, in writeShape
    dxfobject.append(dxfLibrary.PolyLine(getWire(wire,nospline), [0.0,0.0,0.0],
  File "/home/colin/Downloads/free-cad/Mod/Draft/importDXF.py", line 1002, in getWire
    mp = fcgeo.findMidpoint(edge)
  File "/home/colin/Downloads/free-cad/Mod/Draft/draftlibs/fcgeo.py", line 523, in findMidpoint
    perp.normalize()
Additional InformationExporting a similar looking object from another file, DFXTest3 attached, does not create the exception. Both objects were created by cutting and pasting from other FreeCAD documents.

Modifying the file Mod/Draft/importDXF.py to avoid the exception outputs a valid DXF file but with errors in the geometery. Both files display visually correct models in the modelling window.

colin@cs-sis-gcs-laptop:~/Downloads/free-cad$ diff /home/colin/Downloads/free-cad/Mod/Draft/importDXF.py_orig /home/colin/Downloads/free-cad/Mod/Draft/importDXF.py_cs
1002,1015c1002,1016
< mp = fcgeo.findMidpoint(edge)
< v2 = edge.Vertexes[-1].Point
< c = edge.Curve.Center
< angle = abs(fcvec.angle(v1.sub(c),v2.sub(c)))
< # if (fcvec.angle(v2.sub(c)) < fcvec.angle(v1.sub(c))):
< # angle = -angle
< # polyline bulge -> negative makes the arc go clockwise
< bul = math.tan(angle/4)
< # the next bit of code is for finding the direction of the arc
< # a negative cross product means the arc is clockwise
< tang1 = edge.Curve.tangent(edge.ParameterRange[0])
< tang2 = edge.Curve.tangent(edge.ParameterRange[1])
< cross1 = Vector.cross(Vector(tang1[0][0],tang1[0][1],tang1[0][2]),Vector(tang2[0][0],tang2[0][1],tang2[0][2]))
< if cross1[2] < 0:
---
> if (edge.Vertexes[0].Point != edge.Vertexes[-1].Point) :
> mp = fcgeo.findMidpoint(edge)
> v2 = edge.Vertexes[-1].Point
> c = edge.Curve.Center
> angle = abs(fcvec.angle(v1.sub(c),v2.sub(c)))
> # if (fcvec.angle(v2.sub(c)) < fcvec.angle(v1.sub(c))):
> # angle = -angle
> # polyline bulge -> negative makes the arc go clockwise
> bul = math.tan(angle/4)
> # the next bit of code is for finding the direction of the arc
> # a negative cross product means the arc is clockwise
> tang1 = edge.Curve.tangent(edge.ParameterRange[0])
> tang2 = edge.Curve.tangent(edge.ParameterRange[1])
> cross1 = Vector.cross(Vector(tang1[0][0],tang1[0][1],tang1[0][2]),Vector(tang2[0][0],tang2[0][1],tang2[0][2]))
> if cross1[2] < 0:
1018c1019
< points.append((v1.x,v1.y,v1.z,None,None,bul))
---
> points.append((v1.x,v1.y,v1.z,None,None,bul))
TagsNo tags attached.
FreeCAD Information

Activities

2011-11-11 15:36

 

DXFTest.fcstd (Attachment missing)

2011-11-11 15:37

 

DXFTest3.fcstd (Attachment missing)

2011-11-11 15:37

 

dxftest.png (Attachment missing)

2011-11-11 15:37

 

dxftest3.png (Attachment missing)

2011-11-11 15:39

 

VisualComparison.png (Attachment missing)

cstrachan1

2011-11-11 15:40

reporter   ~0001278

Ubuntu 11.10 Linux, FreeCAD compiled from svn: updated and compiled 10th Nov 2011.

yorik

2011-11-17 14:34

administrator   ~0001303

fixed in r5145

Issue History

Date Modified Username Field Change
2011-11-11 15:36 cstrachan1 New Issue
2011-11-11 15:36 cstrachan1 File Added: DXFTest.fcstd
2011-11-11 15:37 cstrachan1 File Added: DXFTest3.fcstd
2011-11-11 15:37 cstrachan1 File Added: dxftest.png
2011-11-11 15:37 cstrachan1 File Added: dxftest3.png
2011-11-11 15:39 cstrachan1 File Added: VisualComparison.png
2011-11-11 15:40 cstrachan1 Note Added: 0001278
2011-11-12 11:14 wmayer Status new => assigned
2011-11-12 11:14 wmayer Assigned To => yorik
2011-11-17 14:34 yorik Note Added: 0001303
2011-11-17 14:34 yorik Status assigned => closed
2011-11-17 14:34 yorik Resolution open => fixed
2011-11-17 14:34 yorik Fixed in Version => 0.12