View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004416 | Draft | Bug | public | 2020-08-03 19:05 | 2020-11-11 02:41 |
Reporter | jeb6kids | Assigned To | chrisb | ||
Priority | normal | Severity | block | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | Dell Vostro | OS | Microsoft Windows 10 Pro | OS Version | Version 10.0.183 |
Summary | 0004416: "Cannot normalize null vector" in Draft2Sketch | ||||
Description | I 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:
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 Reproduce | Open attached *.FCStd file in FreeCAD 0.19 Navigate to the Draft workbench Select path864 Press the "Convert bidirectionally between Draft objects and Sketches" tool | ||||
Tags | import, SVG | ||||
FreeCAD Information | OS: 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) | ||||
|
|
|
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. |
|
@chrisb is this related to https://forum.freecadweb.org/viewtopic.php?f=3&t=51004 ? |
|
I have mentioned this problem in this thread, Improvements in SVG. The problem was first reported in Regression in Draft To Sketch, with reference to particular commits that broke the behavior. The problem is that when importing edges from an SVG file, the importer creates Edges that are of curve type "BSplineCurve". This is done even for straight edges that could be of type "Line" instead. The code cannot compute a normal vector for these BSplines (actually straight lines), and thus produces an error when trying to normalize the null vector (0,0,0). In this thread, SVG cannot be converted to a sketch, Chris_G mentions that the normal calculation for closed edges doesn't work either. So a different way to calculate the normal should be used. This is a separate problem; the issue with the "straight BSplines" should still be addressed. |
|
Was this fixed by PR https://github.com/FreeCAD/FreeCAD/pull/3954 ? |
|
@chrisb, JFYI, I'm trying to associate the commits with tickets before I close tickets. It seems like a good way to easily understand how bugs have been fixed. FreeCAD master aa88f3de |
FreeCAD: master aa88f3de 2020-10-10 02:13:46 marioalexis Committer: yorik Details Diff |
Improve make_sketch and geometric related functions |
Affected Issues 0004416 |
|
mod - src/Mod/Draft/DraftGeomUtils.py | Diff File | ||
mod - src/Mod/Draft/draftgeoutils/edges.py | Diff File | ||
mod - src/Mod/Draft/draftgeoutils/geometry.py | Diff File | ||
mod - src/Mod/Draft/draftgeoutils/offsets.py | Diff File | ||
mod - src/Mod/Draft/draftgeoutils/wires.py | Diff File | ||
mod - src/Mod/Draft/draftguitools/gui_draft2sketch.py | Diff File | ||
mod - src/Mod/Draft/draftmake/make_sketch.py | Diff File | ||
mod - src/Mod/Draft/draftobjects/patharray.py | Diff File |
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 | |
2020-10-10 14:05 | Kunda1 | Tag Attached: SVG | |
2020-10-10 14:06 | Kunda1 | Note Added: 0014821 | |
2020-10-10 22:27 | vocx | Note Added: 0014831 | |
2020-10-22 11:21 | Kunda1 | Tag Attached: import | |
2020-11-10 16:52 | chennes | Note Added: 0014971 | |
2020-11-11 00:01 | chrisb | Assigned To | => chrisb |
2020-11-11 00:01 | chrisb | Status | new => closed |
2020-11-11 00:01 | chrisb | Resolution | open => fixed |
2020-11-11 02:41 | Kunda1 | Note Added: 0014972 | |
2020-11-11 02:41 | Kunda1 | Changeset attached | => FreeCAD master aa88f3de |