Creating a thread: Unexpected results

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Creating a thread: Unexpected results

Post by abdullah »

Dear all,
This is my first post.

I am trying to create a cutting profile to create a thread in a cylinder. I am creating the cutting profile by sweeping a trapezoidal profile along an helix path. Then I use this cutting profile to boolean cut a cylinder and create the thread.

I have come to different results modifying parameters that in my opinion should not alter the result. I do not know if this is a bug or it is simply that it is beyond my understanding.

I am using FreeCAD from git repository:

OS: Ubuntu 12.04.4 LTS
Platform: 64-bit
Version: 0.14.3052 (Git)
Branch: master
Hash: 88ff8076cdbcca2a52c13f40d1cb14df220b3c55
Python version: 2.7.3
Qt version: 4.8.1
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.5.0

Attached you will find the fcstd file I am working in.

What I expect to obtain is Helixthread2.png:
Well cut "tool" path
Well cut "tool" path
Helixthread2.png (188.3 KiB) Viewed 9108 times
The cylinder (extruded sketch) is 20 mm high, but I need at least 22.5 mm to completely finish the thread. However, if I use 22.5 mm Helixthread1.png is generated:
Not well cut "tool" path
Not well cut "tool" path
Helixthread1.png (187.84 KiB) Viewed 9108 times
To generate the "expected result" I have to put 25 mm.

As far as I understand, not only there is no need to enlarge the helix over 22.5 mm to finish the thread, but the "wrong" "unexpected" cut occurs well before 20 mm in Z axis, that should be covered by the 22.5 mm helix (in fact, with a height of helix of 20 mm there is no problem with the cut, but the thread is not totally finished).

I would appreciate if someone could confirm it is a bug, and if it is not, I would then appreciate an explanation of why it happens.

Thanks in advance.
Attachments
GardenStick.fcstd
(410.83 KiB) Downloaded 196 times
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Creating a thread: Unexpected results

Post by bejant »

Reducing the height of the helix causes Sweep to intersect itself, which in turn causes Sweep to fail. There's only about .5mm clearance between the turns from one to the next.

By changing the height of the helix you're also changing the pitch; not sure if that is your intention.
You hay want to change the number of turns instead...
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Creating a thread: Unexpected results

Post by NormandC »

abdullah wrote:OS: Ubuntu 12.04.4 LTS
Platform: 64-bit
Version: 0.14.3052 (Git)
You've installed FreeCAD from the Daily Builds PPA, right? Is there any reason why you are not updating your package? There have been almost 500 commits since that version. It has tons of fixes, and it also uses the most recent Open CasCade (OCC) version available.

Current one as of right now is

OS: Ubuntu 12.04.4 LTS
Platform: 64-bit
Version: 0.14.3512 (Git)
Branch: master
Hash: 90f2fc203466dbbb81ad26849eb3dd4b7b53f326
Python version: 2.7.3
Qt version: 4.8.1
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.7.0
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Creating a thread: Unexpected results

Post by bejant »

Or change the cutting profile...
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Creating a thread: Unexpected results

Post by NormandC »

bejant wrote:By changing the height of the helix you're also changing the pitch
Changing the helix height has no incidence on the pitch; it's an independent parameter.
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Creating a thread: Unexpected results

Post by NormandC »

Abdullah,

I forgot to welcome you here. :)

I've tested your file, and indeed the results are inconsistent. The first time I changed the helix height to 22.5mm, the Cut was generated correctly. But I then closed your file and reopened it to try again, and now it fails me every time. Even changing it to 22.5mm then back to 25mm won't heal the Cut object.

Honestly, threads are problematic in FreeCAD for various reasons, one of them being the weakness of the underlying geometric modeling kernel, OCC.

I find it helps if you make your cylinder higher than the sweep on both ends, cut the cylinder with the sweep, then cut the top and bottom of the cylinder. What may also help is to rotate the cylinder so its seam does not meet with the start and end of the sweep. The OCC kernel does not deal well with edge and face tangency.

Here, since your cylinder is not a part primitive, but made with Part Design features, attempting to rotate it will have no effect. You would have to rotate the base sketch, that is the first sketch that generated the first solid feature. Here that would be "Sketch". If you're unsure of the relations between your different features, use the Dependency Graph in the Tools menu. You will have to install graphviz from your package manager of choice.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Creating a thread: Unexpected results

Post by abdullah »

You guys rock!! 4 replies in a couple of hours!! Thanks to you both!!

I reply to your questions:
I didn't use the PPA. I cloned from github and compiled it (probably some time ago). I did so because I intend to involve myself in the project (a lot to learn before that though). Probably I should pull from the repository more often.. Thanks for pointing out the OCC version issue. I will look further into it.

When the cut won't heal, I think it helped to open anew+remove cut+remove helix+make a new helix+make a new cut. It is not a solution, but a (cumbersome) work-around. Just if someone reads this and is stuck there.

I am not in front of the computer now, so I can not check your proposal, but considering your explanation on OCC, it sounds good. I will try it, hopefully tomorrow, and report back.

I already have the dependency graph working. But thanks for pointing it out.

You gave me a very complete answer. Thanks!!
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Creating a thread: Unexpected results

Post by NormandC »

abdullah wrote:I did so because I intend to involve myself in the project (a lot to learn before that though).
The devs will certainly welcome help, in any form. I do not code myself, but I maintain the FreeCAD PPA, with occasional help from wmayer, one of the devs, when I get stuck.
abdullah wrote:Probably I should pull from the repository more often.
And after the first compile, it's quite quick (less than 2 minutes) if you do it regularly! Compile on Unix - Updating the source code

If you add the Daily Builds PPA to your software sources, you will be able to update the liboce libraries to v0.15, which is based on OCC 6.7.0. If you don't know, OCE stands for Open Cascade Community Edition, it's a community project forked from OCC (which is made by a company) but fully compatible. Its main advantage is it's easier to compile on Linux. Since Ubuntu 12.04 it has replaced OCC in the official repos.

Alternatively I had set up a separate PPA for OCE, but I requested and was granted more storage space on the Daily Builds PPA to be able to copy the packages there so the OCE PPA would not be needed by FreeCAD. I still don't know if we'll keep the OCE PPA.
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Creating a thread: Unexpected results

Post by jmaustpc »

Welcome Abdullah

There have very recently been some bug fixes related to Part Helix....I assume from the pictures you have used the Part WB helix, if so you need to update as the helix bug fixes are more recent than your FreeCAD version.

If you install OCE0.15 or OCC greater than 6.6.0, then the Part wb Check Geometry tool will have more features i.e. it will find invalid shapes that earlier versions can't find.

Jim
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: Creating a thread: Unexpected results

Post by ulrich1a »

Here is a guide how to make a thread with the gui. It makes a thread with the z-axis as the thread-axis. The Thread_cut_profile makes a standard screw profile according to ISO.
1. make a cut profile as given in the attachment. Edit the sketch and set the pitch and the nominal diameter according to your needs. Filter the constraints to named, in order to see those constraints.
2. make a helix1 with height identical to the pitch and the pitch identical to the thread pitch and a helix radius of 0.42*nominal diameter of the thread.
3. Sweep the cut profile along the helix1. Set make solid and frenet to true.
4. Make a circle with nominal radius of the thread in the x-y-plane.
5. Make a face from the circle. (Part-workbench: advanced utility to create shapes)
6. cut the face with the sweep profile
7. make a clone from the cut (Draft workbench)
8. Downgrade the clone in order to get a wire. (Draft workbench)
9. Make a helix with radius of nominal radius of the thread and a pitch of the thread and the height of the needed thread.
10. Sweep the wire along the helix. Set solid and frenet to true.
You are done. The thread may not look good, so the tesselation parameter in the Preferences, Part design, Shape view may be set to 0.1%. The thread I made with this guide was valid in the geometry check.

Ulrich
Attachments
Thread_cut_profile_published.fcstd
(4.32 KiB) Downloaded 614 times
Post Reply