View Issue Details

IDProjectCategoryView StatusLast Update
0003787DraftBugpublic2020-06-16 14:18
Reporterrschaeuble Assigned Tocarlopav  
Status closedResolutionfixed 
Platformx64OSWindowsOS Version10
Product Version0.18 
Target Version0.19Fixed in Version0.19 
Summary0003787: Can't add point to wire
DescriptionAfter creating a wire in the draft workbench, I'm unable to add a point to it. Whenever I try it, I get an exception in the report view:
Exception (Sun Jan 20 23:22:31 2019): In bool __cdecl Part::GeomCurve::closestParameter(const class Base::Vector3<double> &,double &) const in src\Mod\Part\App\Geometry.cpp:566 
<class 'Base.FreeCADError'>
Traceback (most recent call last):
  File "C:\Users\Rolf\Downloads\FreeCAD_0.18.15656_x64_dev_win\Mod\Draft\", line 4188, in action
  File "C:\Users\Rolf\Downloads\FreeCAD_0.18.15656_x64_dev_win\Mod\Draft\", line 4429, in addPoint
Base.FreeCADError: {'swhat': '', 'sfunction': 'bool __cdecl Part::GeomCurve::closestParameter(const class Base::Vector3<double> &,double &) const', 'btranslatable': False, 'sfile': 'C:\\Users\\Chris\\GitHub\\FCAutoBuild\\var\\freecad-git\\src\\Mod\\Part\\App\\Geometry.cpp', 'sclassname': 'class Base::CADKernelError', 'breported': True, 'sErrMsg': '', 'iline': 566}

Forum entry:
Steps To Reproduce
  • Open FreeCAD and create new document
  • Switch to Draft workbench.
  • Create a multipoint DWire (3 points / 2 segments are enough).
  • Finish the wire by pressing "A".
  • Select the wire and press the "Edit the active object" button in the toolbar.
  • In the combo view, press the "add points" button.
  • Move the mouse over one of the segments on the DWire (it will become yellow), then press the left mouse button.
Additional InformationVersion Info
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15656 (Git)
Build type: Release
Branch: master
Hash: a60b6957db228c42a00a1e002a415cbb8309d3c8
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)

I've tried both the "regular" x64 build as well as the Conda build, with same results.
TagsNo tags attached.
FreeCAD Information



2019-09-05 19:58

administrator   ~0013536

@wmayer writes:

I can confirm the problem.

In the error report GeomCurve::closestParameter is mentioned and for B-splines or Bezier curves this function didn't work as expected when a point cannot be projected. For that case the first or last point is used depending on which is closer to the given point. But because both curve types are not of type Geom_TrimmedCurve it raised an exception. This is fixed with [commit]041a550815e00[/commit].

After the above fix adding points still doesn't work and adding some print() statement into reveals why. The computed points never lie on the DWire and apparently the placement information of the DWire is lost at some point. Thus, the further computation is incorrect.
So, if you reset the placement of the DWire adding points suddenly works as expected.

Btw, I find it a bit odd to compute a B-spline curve out of a DWire to get the projection point. A DWire is a polyline (open DWire) or polygon (closed DWire) and the inner corners will never be correctly described by a B-spline curve. This results into incorrect behaviour when adding a new point close to an existing corner.

It is actually pretty simple to determine if a projected point lies within a line segment.
Let's say you have a line segment described by P1 and P2 and an arbitrary point Q.
Now image an infinite line g that goes through P1 and P2 then the parameter t (which is a float) of the projected point can be obtained with:

t = (Q-P1)*(P2-P1)/((P2-P1)*(P2-P1))
If t is in the range [0,1] then it lies inside the line segment and outside otherwise. The requested point can be computed with

P = (1-t)*P1 + t*P2

Now to compute the closest point to a DWire go through all line segments and check if the projection is inside and use that with the minimum distance to the given point. If no such line segment exists then determine the closest corner point.



2019-11-12 23:15

developer   ~0013824

I made quite a lot of changes to draft edit since that version. Is it working as expected in 0.19?


2020-01-11 12:31

administrator   ~0014047

@rschaeuble care to test latest 0.19pre ?


2020-06-14 19:45

developer   ~0014541

I'm for closing also this bug. I can't reproduce with current upstream masted. And that part of the code has been refactored i think. @Kunda1, @wmayer, what do you think? can you reproduce it now?


2020-06-16 09:35

administrator   ~0014557

I have tested it with v0.18.4 and it works most of the time but sometimes it silently fails.

With v0.19 I couldn't test at all because when trying to edit a Wire there are no buttons any more to add/remove points.


2020-06-16 10:00

developer   ~0014558

@wmayer buttons have been moved to the context menu (Alt+click or pressing E key). It's something quite hidden, I know. (I wanted it in the context menu but was not able to do it).
The reason is that Draft Edit now enables multi object editing and the options in the menu change according to the clicked object or to the clicked node.
But if even you could't spot that... perhaps this really means it's not good...


2020-06-16 12:23

administrator   ~0014561

OK, found it now. Yes, the tool seems to work reliably now. So yes the ticket can be closed as fixed.


2020-06-16 12:55

developer   ~0014562

Nice, @wmayer, if you have some hints to enable the actions to be added to the right click context menu on the fly instead of using another dedicated context menu let me know!
(I was thinking to implement better the pivy graphics nodes by looo, so perhaps I can also ask him)


2020-06-16 12:56

developer   ~0014563

Solved during 0.19 dev cycle.


2020-06-16 14:18

administrator   ~0014565

You can adjust the function ContextMenu() of the DraftWorkbench. If the recipient is "View" (that's the 3d view) you can check if an object is in edit mode to add points you can add the command.

However, you still have a lot of other commands in the context-menu and it's not very convenient for the user to click the right item afterwards.

A better way is to use the task panel and add watchers to it. With a watcher you have a fine control when to show the command or not. As an example have a look at DraftCreateWatcher.

Issue History

Date Modified Username Field Change
2019-01-21 18:57 rschaeuble New Issue
2019-09-05 19:58 Kunda1 Note Added: 0013536
2019-09-05 19:58 Kunda1 Status new => confirmed
2019-09-05 19:58 Kunda1 Target Version => 0.19
2019-11-12 23:15 carlopav Note Added: 0013824
2020-01-11 12:31 Kunda1 Note Added: 0014047
2020-01-11 12:31 Kunda1 Status confirmed => feedback
2020-06-14 19:45 carlopav Note Added: 0014541
2020-06-16 09:35 wmayer Note Added: 0014557
2020-06-16 10:00 carlopav Note Added: 0014558
2020-06-16 12:23 wmayer Note Added: 0014561
2020-06-16 12:55 carlopav Note Added: 0014562
2020-06-16 12:56 carlopav Assigned To => carlopav
2020-06-16 12:56 carlopav Status feedback => closed
2020-06-16 12:56 carlopav Resolution open => fixed
2020-06-16 12:56 carlopav Fixed in Version => 0.19
2020-06-16 12:56 carlopav Note Added: 0014563
2020-06-16 14:18 wmayer Note Added: 0014565