Fasteners workbench for FreeCAD

Update 21-Jul-2015: Updated to Ulrich’s V2.0 screw_maker. More fasteners and nuts!

Update 01-Oct-2015: Add Bill-Of-Material generation

Many times when I design parts in FreeCAD (Specially Sheet Metal) I need to add standard fasteners such as screws, press-nuts, stand-offs etc… I used to add them manually, usually just as a rough shape, just to have it in the drawing for clearance. Fortunately, volunteers from the FreeCAD community begun to release addons  to generate such standard parts automatically. One of these addons is the very nice macro by Ulrich Brammer, that generates several types of screws with high accuracy and conformance with the standard.

To make it easier to use, and also conform with parametric nature of FreeCAD, I decided to write a simple workbench wrapper with WYSIWYG Icons and some controls.

Installation:

Starting from Frecad 0.17, The installation is simple and done using FreeCad’s Add-on manager (Under ‘Tools’ menu)

For off-line manual installations:
Download this file: FastenersWb
Extract the file into FreeCAD Mod directory.
(On Windows its somewhere like “C:\Program Files\FreeCAD 0.18\Mod”, On Linux: “~/.FreeCAD/Mod”  , create it if not exist)
That’s it.
Under the Mod directory you should see a new directory called Fasteners:

FSdir

How to use:

Usage is pretty straightforward:

Start a new document in FreeCAD. Select the Fasteners workbench from the drop-down list.

A series of screws will show on the toolbar:
FSToolbar

Simple Usage:
Clicking on any of the screws will create this screw in the origin position with default size. To change size/length select the newly created screw, then go to the data tab in the property panel, there you can change diameter and length. (For now it is in metric standard):

FSParams

Changing the “thread” property to “true” will render the screw threads as well. Please note that generating threads takes considerable amount of time, during which, FreeCAD will not be responsive.
The invert and offset properties are only applicable to attached fasteners. See next.

Attached fasteners:
Fasteners can also be attached to features in other parts. To attache a screw to a part, the part must have features with circular edges, such as holes. To attach screws to holes, select the desired circular edge or several edges (You can also select a face if you want to select all holes in that face):
FSSelect

Now click on the desired screw. A screw will be placed on each of the selected features, trying to match the screw size to the hole size:
FSCreated

You can now, like before, change diameter and length from the properties panel. If you wish the screw to hover above the hole, you can set the “offset” property  to the desired distance. Sometimes the screw does not detect the direction correctly and appears upside down. To correct this change the “invert” property to true, or select the screw and press the Flip button (FSFlip) in the toolbar.

To attach an existing fastener to a different feature, select the screw, then control-select the new feature:
FSSelMove

Now press the Move button (FSMove) in the toolbar. The screw will move to the new location:
FSMoved

An attached screw will move with the part it is attached to. If you wish to detach the screw from the parent part, simply select only the screw, then press the move button. The screw is now detached and can be moved individually.

Simplifying objects

It is important to note that if you wish to share FCStd files that contains fasteners (or parts from other custom parametric workbenches)  with other people, they must install these workbenches as well, or else they will get errors when trying to use them.
However, if you just want to share the resulting parts, with no need to change object’s parameters, you can use the Simplify (SimplifyObj) function, to convert the fasteners to simple shapes. They will appear as new Shape parts in the model tree. You can then delete the original fasteners and save as a simple FCStd that can be read and used on any FreeCAD installation.

Source Code:

For those who are interested, GitHub code can be found here.

Future planned features:

The current workbench is just a wrapper to the screw_maker macro. As so it shows only screws (and a washer). I hope to soon add some press-nuts(added), studs(added) and stand-offs(added).

Once again, many thanks to Ulrich Brammer for his great screw maker macro.

That’s all folks!
Hope it helps.

 

71 Responses to 'Fasteners workbench for FreeCAD'

  1. Harry D. says:

    Impressive workbench – well done. Thanks! 🙂

  2. hpb says:

    Your FB workbench works great. I really like it. In my actual project I use a lot of screws, washers and nuts. The BOM feature is also very helpful.
    Would it be possible to count all the rest of the parts in project? I’m using the Assembly2 WB for building up my project.
    Thanks a lot for your well done WB

    Regards hpb

  3. Franck says:

    Is that possible for have inch stew

  4. Thorsten says:

    Fastastic work! Saves me a lot of time.

    Is it possible to include a turning parameter? I need to turn some of the screws for perfect fit with the threads inside the holes.

    Thank you very much.

  5. cShellPro says:

    The fastener workbench looks promising, however I can’t get it to work. After having installed it in my Mod folder, all I get is:

    “invalid literal for int() with base 10: ‘Unknown’

    I’m not sure what I can do to make it work.

  6. Hi,

    the problem is that the function in FastenerBase.py contains a test of the FreeCAD version and subversion. On my Debian 8.4 Linux box, the FreeCAD I have returns as version:

    [‘0′, ’16’, ‘Unknown’, ‘Unknown’, ‘Unknown’]

    and obviously the code snippet where tthe subversion is tested fails.

    Just changing the code snippet to this:

    #DropButtonSupported = int(FreeCAD.Version()[1]) > 15 and int(FreeCAD.Version()[2].split()[0]) >= 5165
    #RadioButtonSupported = int(FreeCAD.Version()[1]) > 15 and int(FreeCAD.Version()[2].split()[0]) >= 5560
    DropButtonSupported = int(FreeCAD.Version()[1]) > 15
    RadioButtonSupported = int(FreeCAD.Version()[1]) > 15

    removes the error. Probably there is a more refined way to achieve the same result, but at least this pinpoints the issue for me.

    Cheers

    Lorenzo

    • shaise says:

      Lorenzo,

      Yes, I found that myself and solved it (I decided that ince ver 0.16 is already stable, I just disregard the build number).
      The latest version has this fix.

      Thanks!

  7. GoyoR says:

    Tanks !!!!!!!!!!!

  8. Colin says:

    Love this works great, But is there a way to show the fastener in the drawing workbench I have tried but no success
    any hints would be great thanks

    • shaise says:

      Hi Colin,
      The drawing workbench works on a single part, not an assembly. A crude workaround is to fuse the part with the fastener, then bring the fused part to the drawing. I think you better post this question in the freecad forum, as I guess many encountered your case:
      http://forum.freecadweb.org

  9. molecular_models says:

    Hi, my first foray into 3D printing and design, and I must say Freecad rocks 😉

    The screwmaker makes total sense – but am I missing something? Do these screw threads work? Or am I supposed to make the threads then “cut” the screw from the surrounding block?

    Or perhaps for an M8 screw, have a hole that is 8.1?

    Simply looking for a worked example where the threads work. Although they may wear down, there are scenarios that an all-in-one construction would be critical.

    • molecular_models says:

      To expand further – I put some 4mm holes in a design I printed (for wood screws!), and investigated some metric bolts instead. A big of googling and I found this -> http://www.shender4.com/metric_thread_chart.htm

      which gives different drill holes depending on the threads. So when I used the Screwmaker and it “matched” the 4mm hole, why did it pick M4? Not M5? I understand this is subtle as it is depends on the threads, but I am not familiar with the conventions used, or is this is the correct approach.

      • shaise says:

        Hi,

        There are 2 ways to match a screw:
        1. pass through – when you want to put a bolt in a hole and close it with a nut on the other side (no threading in the matter) In this case a 4mm hole will pick an m4 screw
        2. Thread in – when you want the screw to screw into the mater. In this case a 4mm hole will pick an M5 screw.

        A small button in the toolbar will let you select which mode you want to work on.

        shai

  10. fourchette says:

    thank you ! thank you ! thank you !!!!

    thank you so much for the fastener wb ! i just love it

    However, i often use arrays to properly align holes and screw. I have noticed that while repeating screws and nuts with arrays, they are not counted in the generated BOM. Can it get fixed ? Assuming I want to implement it, where should i look first then ?

    anyway, keep up the good work

    fourchette

  11. Alexander says:

    God bless you! This great workbench save me a huge amount of time!

  12. Paul Perrin says:

    Fantastic – love this thing… I am doing loads of stuff on my new 3d printer… all those adaptors etc that are such a pain to find…

    The bits that I have found missing that would be really useful is M26 which is a standard for microphone stand threads (I created a 3/4″ circle and threaded it which I think will work…), and 1/4″ UNC which is the standard camera/tripod thread… which I can’t seem to fake up cos its not a metric thread 🙁

    • shaise says:

      Hi Paul,
      This workbench is only a GUI wrapper over the screwMaker macro made by Ulrich. Unfortunately this macro supports only metric screws. You can try and ask Ulrich for extra screws at the freeCad forum

  13. sal says:

    Works really nice!

  14. Joan says:

    OMG!! Great!!! I’m proud to use this amazing free soft … a lot of wise people sharing his talent to everyone!
    thank you so much

  15. Karsten says:

    Hi shaise

    Really great work. Thanks for the workbench.

    I have a problem when using the QT5 version of freecad running on a mac. When I try to generate countersinks the console shows me multible error messages.

    Have you ever tried with QT5? Can you please have a look if you can update your workbench supporting QT5?

    Kind regards
    Karsten

    • shaise says:

      Try the github version. It should be QT5 compatible.
      https://github.com/shaise/FreeCAD_FastenersWB

      • Karsten says:

        Thanks for the reply. I already tried the current git version. But no success.

        On Mac with the latest 0.17 build I get the following error. I asked the internet and it says that this is somehow related to the incompatibility from qt4 and qt5.

        Running the Python command ‘FSFillet’ failed:
        Traceback (most recent call last):
        File “/Users/Karsten/Library/Preferences/FreeCAD/Mod/FreeCAD_FastenersWB-master/CountersunkHoles.py”, line 673, in Activated
        Gui.Control.showDialog(FSTaskFilletDialog(None))
        File “/Users/Karsten/Library/Preferences/FreeCAD/Mod/FreeCAD_FastenersWB-master/CountersunkHoles.py”, line 445, in __init__
        FSFilletDialog.ui.fillTable(FSFilletDialog, self.baseObj, edgelist)
        File “/Users/Karsten/Library/Preferences/FreeCAD/Mod/FreeCAD_FastenersWB-master/CountersunkHoles.py”, line 163, in fillTable
        header.setResizeMode(0, QtGui.QHeaderView.Stretch)

        ‘PySide2.QtWidgets.QHeaderView’ object has no attribute ‘setResizeMode’

  16. Ruru says:

    Shaise and Ulrich you are genious, thanks a lot for this nice work.
    On my Freecad 0.16 Linuxmint 18.1 64bits I found a problem on the Fastener workbench.
    The button allowing change between pass through/Thread in change just with the first click, then don’t change anymore.
    Something to do ?

    • shaise says:

      What version do you have? In my version its two separate buttons, not one.

      • Ruru says:

        I use Freecad 0.16 rev 6712(Git) 64 bits.For Fastener I have V0.2.13 01 Oct 2015 in the release notes of README.md
        I have 2 buttons (tap-hole and pass-hole), but sometimes I get just one (pass-hole). I have to re-load Freecad !!!! First problem.
        Then I did a part with 2 holes 4mm diameter and 2 holes 6mm.
        I select tap-hole, then 1 hole 4mm and 1 6mm, then a screw. I got a M5 and a M8 ?
        Now I select pass-hole, the 2 others holes, and I got the same (M5 instead M4, and M8 instead M6) Second problem.

  17. Biniamien Southgate says:

    Hi,

    Thanks for the great library.

    Just while using the press nut fasteners, if i make my hole the recommended diameter for the press nut and i place the press nut, the hole is way too big.

    The press nut diameter seems to be too small.

  18. johno says:

    very great! Thank you so much!! :-))

  19. Andreas Brandner says:

    Thank you very much !!!!

  20. Otto Klaasen says:

    Thanks, nice work.

    I 3d printed a M12 nut and bolt, did not fit. I printed the bolt again at 98% size in x and y and it fits perfect. Also tried a M6 bolt and a M6 nut, but it seems the nut is printed as M5, it fits a metal M5 perfectly. So maybe a bug in the sizes or maybe an issue with the tolerances of 3d printing. I tried another nut to print as M6 but it came out as M5. The fact that the printed M6 nut fits a metal M5 bolt perfectly makes me suspect the M6 nuts are printed as M5, the question now how to print M6 nuts correctly, i am not a mechanical designed, just a hobby guy, i am getting nuts now 🙂

  21. Brian says:

    Wonderful workbench! I too am using it for 3D-printed parts, to print parts that screw together. It would be an incredibly useful feature to be able to specify some sort of thread scaling factor to push them outward from the axis of rotation, so that using a threaded rod object as a tool to cut threads in another object will leave sufficient tolerance (as-is, it results in an interference fit). I might try to add the feature myself…we’ll see how it goes; I am not a Python expert by any means!

  22. Bram Kerkhofs says:

    Great workbench!
    Is there a way of using it in a macro script?

    • shaise says:

      There is a macro called ScrewMaker. this workbench is using it. You can use this macro as well. You can get it same way using the addon manager.

  23. Stephen Howells says:

    Thanks for this useful workbench. I need to be able to specify bolt lengths exactly- Well every mm would do if 0.1mm is too difficult to implement. The problem is, if you have,say, 19mm of material and you use 20mm for the bolt length then any nut is sunken in the material. The drop down box would be better (IMO) being a standard number field.

    • shaise says:

      The workbench is based on existing macro that generate bolts. Unfortunately this macro have only standard sizes.

  24. Jason Tamer says:

    It would be great if the size range could be extended – I work with small parts, where we use down to M1. Also the addition of set screws with e.g. hex drive would be great as well.

  25. Wade Beatty says:

    This workbench is great! Thank you for your work.

  26. Torben Larsen says:

    Thanks for this very useful library – most constructors will need it.
    What if I would add some threads to a part, can I use a ScrewTap? How can I make the add the screwtap to the part? Sorry if this is a very naive question.
    Best regards
    Torben Larsen

    • shaise says:

      The best way to ask questions is via the FreeCad forum: http://forum.freecadweb.org.
      any way, most screws can have thread by setting the ‘thread’ property to true.
      if you want to tap a hole in the model, there is a special ‘threaded rod’ fastener
      that can create inner threads by using boolean subtraction.

  27. Ice Walker says:

    Hi,

    Trying to install your workbench under FreeCAD 0.18.4.
    Get an issue with the csv.reader() instruction line 116 of screw_maker.py.
    There are no ‘unix’ dialect in my csv library (for Python 2.7.17) which seems to be the used at runtime.
    Note that I also have Python 3.6.9 which has the ‘unix’ dialect in its csv library.
    I do not know how to fix this issue, if you know what to do that will be much appreciated.
    Running Ubuntu/Linux.

    Thanks!

  28. Superfix says:

    Please in my Linux Mint 2020 don’t work. I copy the folder “Fastners” in the directory .FreCad\Mod\ but nothing appear in the menù under FreeCAD 0.18.4.

  29. chip says:

    Installing the freecad fasteners workbench doesnt make it show up in freecads addon manager, quick please. I have a course on this and I dont wanna fail because of fastener not working :/

    • shaise says:

      Remove old freecad with all subdirectories.
      Install latest FreeCad 0.19 (from here: https://github.com/FreeCAD/FreeCAD/releases/tag/0.19_pre)
      (addon not working in old versions)
      From the menu select Tools -> Addon Manager
      From the list on the left select fasteners
      on the bottom press “Install/update selected”
      after installation complete, close freecad and reopen it.
      It should be in the list of workbenches now.

  30. Wagner Lipnharski says:

    I have installed the latest version 0.18, but for company security the PC is not able to access internet. So I download the ZIP file Fasteners_V0.2.15 and unzipped the “Fasteners” directory to the \MOD directory, along with the others already there. Restarted FreeCad, but Fasteners option doesn’t appear at the pull-down menu. How to solve it? Thanks.

  31. Wagner Lipnharski says:

    Shaise, I copied the whole \Fasteners to the \MOD of version 0.19, close/open and it did not appear on the pull down menu of WBs… I think both, 0.18 and 0.19 require something else to include into the pull down, not only by the fact that a new folder is copied into the \MOD.

    • shaise says:

      This is very strange, No there is no need to do anything else then to place the /fastener folder inside the /mod one. If this is a windows PC, you can also try to put it under the C:\Users\(your user name)\AppData\Roaming\FreeCAD\Mod
      If this does not help, please try the freecad forum (forum.freecadweb.org). They might better guide you troubleshooting this issue.

  32. Wagner Lipnharski says:

    Yes Shaise, I also copied the \fasteners into the C:\users\userid\AppData\Roaming\FreeCad\… where the macros shows link on Edit Preferences…

    There is an error message though, at Report View upon starting FreeCad 0.18 or 0.19:

    During initialization the error invalid character is identifier (, line1) occurred in C:\users\userid\Appdata\Roaming\FreeCad\Mod\Fasteners\InitGui.py

    The first line of InitGui.py:
    # -*- coding: utf-8 -*-

  33. Wagner Lipnharski says:

    Dear Shaise, I renamed \PARTS to \PARTSxxxx and renamed \Fasteners to \Parts, now the invalid character identifier message is on \Parts… so, something is wrong with this line1… (“, line1) – I don’t know why the text “string” inside of “less than” and “bigger than” was cutout on my previous post…

  34. Wagner J Lipnharski says:

    Dear Shaise, by some suggestions from the forum, used Notepad++ in order to save the text of InitGuy.py with utf8 encoding, and not it works… wow.

    Now when I select the WB from the pulldown menu, error:
    Invalid Syntax (screw_maker.py, line 4362)…
    The line shows: ‘if da None:’
    (if da different than None:)

  35. Wagner Lipnharski says:

    Dear Shaise, by suggestion from the forum, I used Notepad++ and saved the InitGui.py as UTF-8, it worked. wow.
    Now a new error when I try to select the Fasteners from the pull down menu:

    Invalid Syntax (screw_maker.py, line 4362)

    Thank you for your kind support.

  36. Wagner Lipnharski says:

    I finally found your
    https://github.com/shaise/FreeCAD_FastenersWB

    Download the whole set of files, and it works fast.
    No Problems anymore.

    May be there is some problems in your files from
    http://theseger.com/projects/wp-content/uploads/2015/06/Fasteners_V0.2.15.zip

    Thanks a bunch

    • shaise says:

      Oh! really sorry about that… Since the move to internal add-on manager I stopped updating the zip file. Perhaps I need to point to the github repository instead.

  37. joe says:

    This is a great workbench, thanks for all your effort. Ive come across an issue i cant resolve. I want to make effectively a negative of a bolt with a slight offset. So for example i want to make a hex hole that perfectly holds an m5 bolt head. if i simply subtract an m5 bolt from a shape i’m left with an exact m5 hole BUT this will be too tight to fit an m5 bolt especially when 3d print tolerances come in. What i need is something like an m5.2 hole! Any ideas how I can do this? could a future release allow such an ‘offset’? Thanks Joe

    • shaise says:

      There is an option to make the thread wider or narrower to compensate for 3d printer tolerances, but not for the head. But the head is a simple hexagon, so making a hexagon cavity is quite easy to do separately without subtracting a bolt.

  38. Zong says:

    Hello,

    Thank you for a really great workbench we can use for free!

    I have a question. Is it possible that I make the whole piece threaded after specifying the length to be 60 mm or above? It always has half bottom thread instead of the whole piece and there’s this line to separate the two parts. Is there anyway I can get rid of that line and make it threaded the whole piece?

    https://im.ge/i/image.11aAFCT
    This is what I get when making thread true.

    This is what I want to achieve:

    http://cf.shopee.co.th/file/305eccfbd0c835c8ae1e3db41b158012

    Thanks
    Zong

    • shaise says:

      The partly-sized thread is the standard. If you want to make non standard length thread, you can generate the screw without thread at all, then you can generate a die with the length of thread that you want and cut it from the screw.

Leave a Reply

Your email address will not be published. Required fields are marked *

*