New automatic tool to convert STL back to parametric sketches

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
chrisb
Veteran
Posts: 54150
Joined: Tue Mar 17, 2015 9:14 am

Re: New automatic tool to convert STL back to parametric sketches

Post by chrisb »

I should mention, that this was only a test, because I had the model at hand. It exists already in FreeCAD. So you can use it, of course, to improve your algorithm, but you don't have to convert it for me.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
xryl669
Posts: 32
Joined: Fri Jul 31, 2020 1:19 pm

Re: New automatic tool to convert STL back to parametric sketches

Post by xryl669 »

Now it's updated with the new version that seems to work with the big model.
Instead of converting all sketches it can find, instead, you now have to select the plane to sketch.
You'll click on the "Select plane to sketch" button and then on the plane in the 3D view and it'll sketch the plane (visible in the "Sketches" tab).
From there you can export SVG and FreeCAD sketches.

I'm still not completely satisfied with the FreeCAD exporter, since for some sketches, FreeCAD does not succeed solving the constraints the tool has generated (you need to delete some constraint and replace by other until FreeCAD finally accept them). At least, it's finding by itself all the diameters, angles, length, direction and so on (so the most tedious tasks, IMHO).

Available here for testing
User avatar
adrianinsaval
Veteran
Posts: 5544
Joined: Thu Apr 05, 2018 5:15 pm

Re: New automatic tool to convert STL back to parametric sketches

Post by adrianinsaval »

What constrains are giving you trouble? and what error message do you get?
xryl669
Posts: 32
Joined: Fri Jul 31, 2020 1:19 pm

Re: New automatic tool to convert STL back to parametric sketches

Post by xryl669 »

I don't know what are the constraint that fail. The error message is "Solver failed".
There isn't any over contraint, or missing constraint.
In fact, I'm building everything from few constraints: length, angle, same position, and diameter + angles.
Theorically, this should work to completely define a sketch, but FreeCAD solver is mystified by those (I guess the OCC solver does not succeed finding a numerical solution that's matching my own solution).

See the example file, double click on the sketch to edit it. You'll see all constraints and they all are fine, but the solver does not converge. You can remove one or two and it'll then say the sketch is under constrained but if you try to add them back, it's failing again to converge.

To actually have FreeCAD accept it, I need to convert some constraint to "easier" constraint, like "horizontal line" or "vertical line" or "symmetry" and remove the angle constraint between segments for example. Yet, as soon as you have multiple circle/arc, it's hard to get it right.
Attachments
sketch_1.FCStd
(3.44 KiB) Downloaded 27 times
Post Reply