View Issue Details

IDProjectCategoryView StatusLast Update
0004416DraftBugpublic2020-08-05 08:49
Reporterjeb6kids Assigned To 
PrioritynormalSeverityblockReproducibilityalways
Status newResolutionopen 
PlatformDell VostroOSMicrosoft Windows 10 ProOS VersionVersion 10.0.183
Product Version0.19 
Summary0004416: "Cannot normalize null vector" in Draft2Sketch
DescriptionI used Inkscape to create a set of paths to import into FreeCAD.
Upon importing the resulting .svg file, 15 path* Draft objects appeared under my Body. One by one I used the "Convert bidirectionally between Draft objects and Sketches" tool on the Draft workbench to create sketches that appeared also under my Body.

However, when converting one draft object, python threw a red stack trace to the report view:

13:18:15 Traceback (most recent call last):
  File "C:\Users\Master\Downloads\FreeCAD\FreeCAD_0.19.22164-Win-Conda_vc14.x-x86_64\Mod\Draft\draftutils\todo.py", line 167, in doTasks
    Gui.doCommand(string)
  File "<string>", line 1, in <module>
  File "C:\Users\Master\Downloads\FreeCAD\FreeCAD_0.19.22164-Win-Conda_vc14.x-x86_64\Mod\Draft\draftmake\make_sketch.py", line 93, in make_sketch
    if not DraftGeomUtils.isPlanar(shape):
  File "C:\Users\Master\Downloads\FreeCAD\FreeCAD_0.19.22164-Win-Conda_vc14.x-x86_64\Mod\Draft\draftgeoutils\geometry.py", line 286, in isPlanar
    n = getNormal(shape)
  File "C:\Users\Master\Downloads\FreeCAD\FreeCAD_0.19.22164-Win-Conda_vc14.x-x86_64\Mod\Draft\draftgeoutils\geometry.py", line 249, in getNormal
    n = getSplineNormal(e)
  File "C:\Users\Master\Downloads\FreeCAD\FreeCAD_0.19.22164-Win-Conda_vc14.x-x86_64\Mod\Draft\draftgeoutils\geometry.py", line 215, in getSplineNormal
    n.normalize()
Base.FreeCADError: Cannot normalize null vector


I found the "getSplineNormal() function def and added a few debug statements:

def getSplineNormal(edge):
    """Find the normal of a BSpline edge."""
    print( "edge=[{}]\n".format( str(edge) ))
    startPoint = edge.valueAt(edge.FirstParameter)
    endPoint = edge.valueAt(edge.LastParameter)
    print( "startPoint=[{}]\n".format( str(startPoint) ))
    print( "endPoint=[{}]\n".format( str(endPoint) ))
    midParameter = (edge.FirstParameter
                    + (edge.LastParameter - edge.FirstParameter) / 2)
    midPoint = edge.valueAt(midParameter)
    print( "midPoint=[{}]\n".format( str(midPoint) ))
    v1 = midPoint - startPoint
    v2 = midPoint - endPoint
    print( "v1=[{}] v2=[{}]\n".format( str(v1), str(v2) ))
    n = v1.cross(v2)
    print( "n=[{}]\n".format( str(n) ))
    n.normalize()
    return n

This is what was printed out on the Report view:

13:18:15 edge=[<Edge object at 000002265C28A220>]
13:18:15
13:18:15 startPoint=[Vector (-2581.953, -2921.6615, 0.0)]
13:18:15
13:18:15 endPoint=[Vector (-2581.953, -2918.0896000000002, 0.0)]
13:18:15
13:18:15 midPoint=[Vector (-2581.953, -2919.87555, 0.0)]
13:18:15
13:18:15 v1=[Vector (0.0, 1.785949999999957, 0.0)] v2=[Vector (0.0, -1.785949999999957, 0.0)]
13:18:15
13:18:15 n=[Vector (0.0, 0.0, -0.0)]
13:18:15

So it appears that my draft object was a legitimate object, but just happened to contain a bspline that was exactly vertical (having no arc, i.e. a line segment).
Steps To ReproduceOpen attached *.FCStd file in FreeCAD 0.19
Navigate to the Draft workbench
Select path864
Press the "Convert bidirectionally between Draft objects and Sketches" tool
TagsNo tags attached.
FreeCAD InformationOS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22164 (Git)
Build type: Release
Branch: master
Hash: f2a9f712e8d68ee2393d0fe748c02096c4148a32
Python version: 3.8.5
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)

Activities

jeb6kids

2020-08-03 19:05

reporter  

mickeymouse6.FCStd (90,851 bytes)

mikeprice99

2020-08-05 08:49

reporter   ~0014701

I'd just like to confirm that I've found the same problem.

I addition I've discovered that when importing SVGs all the elements are correctly converted, but after the import of elements they are all then converted to BSplines when a Vector transformation is applied. A quirk in importSVG.py ensures a vector transformation is always applied, even if it does nothing useful.

Issue History

Date Modified Username Field Change
2020-08-03 19:05 jeb6kids New Issue
2020-08-03 19:05 jeb6kids File Added: mickeymouse6.FCStd
2020-08-05 08:49 mikeprice99 Note Added: 0014701