Open looooo opened 5 years ago
Sorry to be so late replying. I just noticed this today. Thanks for the feedback.
I looked at your code. Replacing the bspline edges with arcs, where possible, would likely improve the look of the final sweep object, but my method of creating the threadprofile objects might make that a bit tricky. I'll have to think on it some more.
Basically, I make the traditional 2d profile (scaled to 1mm pitch) and place it on the xz plane, then take a straight edge and begin at the bottom of the profile and move it up to the top in 720 increments, taking the intersection to find the x-coordinate at that z-position each step along the way. This is done in a separate macro to create the lists of data for each thread profile ahead of time. Probably there are more elegant ways of doing it, but I'm really just a hack. The data then gets translated into the bspline profile once the minor diameter and pitch are known at runtime. Where the original profile is a simple vertical line the bspline basically becomes a standard arc (but still is a bspline). I could replace those sections with arcs to improve the quality (and likely performance) at least there. In this image the vertical section of the 2d profile circled in red is what could become a standard arc.
But I don't think even that is actually a straight vertical edge, but rather has a very subtle angle to it.
One recent change I made seems to have improved the quality of the sweep object:
#spline.interpolate(obj.Points, PeriodicFlag = True, Parameters = self.knotSeq)
spline.approximate(Points = obj.Points, DegMin = 3, DegMax = 5, Tolerance = .003692, Continuity = 'C3', ParamType = 'ChordLength')
spline.setPeriodic()
The threadprofile objects are now C3 continuity instead of C2. Still not perfect, but much improved.
It would be nice to use a wire (list of edges) instead of one bspline as the profile. This way exact geometry can be created where possible (eg cylindrical faces are created from a arc) and edges are created on sharp corners. An example can be found in the gear-workbench: https://github.com/looooo/freecad.gears/issues/1#issuecomment-535238328
Btw.: Helical projection is a great idea!