Screw Maker

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
mdhill
Posts: 85
Joined: Mon Apr 24, 2017 7:37 pm

Re: Screw Maker

Post by mdhill »

Thanks Ulrich, success!

Mike
rachdatu
Posts: 15
Joined: Thu Jun 22, 2017 10:26 am
Location: Switzerland

Re: Screw Maker

Post by rachdatu »

Thanks again Ulrich for this great macro.

I needed to 3D print a nut for my tripod (1/4" UNC).

I managed to make a few by changing a M6 ISO4032 nut with the following parameters:
In the python script, I modified line 1403:

Code: Select all

'M6':    (1.27,  0.2, 6.75, 9.5, 12.1, 4.7, 3.9, 10.5),
And added some tolerances in 4006 and 4306 like mr_cg suggested it: (0.6 instead of 0.4)

Code: Select all

d = float(d) + 0.6
All in one, the nut is OK. It needs a little force but it can be done with 2 fingers only :-)

For those interested, I have uploaded the design.

Let me know if you change it.
Thanks

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6706 (Git)
Build type: Release
Branch: releases/FreeCAD-0-16
Hash: f86a4e411ff7848dea98d7242f43b7774bee8fa0
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Attachments
nut_tripod.FCStd
(483.17 KiB) Downloaded 149 times
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: Screw Maker

Post by ulrich1a »

I made an update to Screw Maker, in order to play together with Bodies and Parts. The screws do now observe the placement of a Body. If the Body is inside of a Part, the screw is added to the Part as well. I tried to improve the orientation of the screw-placement. So hopefully there are less cases with flipped screws inserted.

Ulrich
Attachments
screw_maker2_2.py.zip
(36.05 KiB) Downloaded 719 times
User avatar
ppemawm
Veteran
Posts: 1240
Joined: Fri May 17, 2013 3:54 pm
Location: New York NY USA

Re: Screw Maker

Post by ppemawm »

Thanks for the update ulrich1a. Works as advertized!
This has been my go-to macro of all time.
"It is a poor workman who blames his tools..." ;)
clytle374
Posts: 172
Joined: Wed Nov 06, 2013 3:58 am

Re: Screw Maker

Post by clytle374 »

Thanks for the update. I think my git build is still got a few issues after the qt5 update. Anyway screwmaker isn't working.

Upon loading freecad I get the these lines, including them incase they are related
cory@cory-laptop ~/buildfreecaddev $ ./bin/FreeCAD
FreeCAD 0.18, Libs: 0.18R13799 (Git)
�� Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2018
##### #### ### ####
# # # # # #
# ## #### #### # # # # #
#### # # # # # # # ##### # #
# # #### #### # # # # #
# # # # # # # # # ## ## ##
# # #### #### ### # # #### ## ## ##

Fasteners workbench Loaded
During initialization the error UI file does not exist occurred in /home/cory/buildfreecaddev/Mod/Draft/InitGui.py
Please look into the log file for further information
During initialization the error UI file does not exist occurred in /home/cory/buildfreecaddev/Mod/Arch/InitGui.py
Please look into the log file for further information
When trying to execute the screwmaker macro I get this
Traceback (most recent call last):
File "/home/cory/.FreeCAD/screw_maker2_2.py", line 5448, in <module>
class ScrewMacro(object):
File "/home/cory/.FreeCAD/screw_maker2_2.py", line 5451, in ScrewMacro
d.ui.setupUi(d)
File "/home/cory/.FreeCAD/screw_maker2_2.py", line 1771, in setupUi
self.retranslateUi(ScrewMaker)
File "/home/cory/.FreeCAD/screw_maker2_2.py", line 1781, in retranslateUi
ScrewMaker.setWindowTitle(QtGui.QApplication.translate("ScrewMaker", "Screw-Maker 2.2", None, QtGui.QApplication.UnicodeUTF8))
<type 'exceptions.AttributeError'>: type object 'PySide2.QtWidgets.QApplication' has no attribute 'UnicodeUTF8'
thanks again
Cory

EDIT: I found this is a problem when migrating from qt4 to qt5 which I was forced into a few months back. https://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5
== QCoreApplication::UnicodeUTF8 is deprecated ==

This enum type used to define the 8-bit encoding of character string arguments to translate(). This enum is now obsolete and UTF-8 will be used in all cases. So remove all instances of QCoreApplication::UnicodeUTF8. For example:
Href_Gui->setWindowTitle(QApplication::translate("Href_Gui", "Url / www", 0, QApplication::UnicodeUTF8));
label->setText(QApplication::translate("Href_Gui", "Text:", 0, QApplication::UnicodeUTF8));
label_2->setText(QApplication::translate("Href_Gui", "Url:", 0, QApplication::UnicodeUTF8));
label_3->setText(QApplication::translate("Href_Gui", "Target / Name:", 0, QApplication::UnicodeUTF8));
to
Href_Gui->setWindowTitle(QApplication::translate("Href_Gui", "Url / www", 0));
label->setText(QApplication::translate("Href_Gui", "Text:", 0));
label_2->setText(QApplication::translate("Href_Gui", "Url:", 0));
label_3->setText(QApplication::translate("Href_Gui", "Target / Name:", 0));
Just FYI
Cory
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Screw Maker

Post by abdullah »

ulrich1a wrote: Sat May 19, 2018 7:42 pm I made an update to Screw Maker, in order to play together with Bodies and Parts.
Thanks. I like this macro/module a lot.

One question: How can I make the screws solid internally?. They are hollow:
Shell_Screw2.png
Shell_Screw2.png (39.83 KiB) Viewed 2655 times
EDIT: Maybe they are not hollow and it is a trick of the clip plane, when exporting the STL and opening it in Slic3r infill is generated...
chrisb
Veteran
Posts: 54201
Joined: Tue Mar 17, 2015 9:14 am

Re: Screw Maker

Post by chrisb »

CheckGeometry tells it's solid and cutting someth e.g. with a boolean cut shows it as well. It must be the meshing which makes it a shell.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Screw Maker

Post by abdullah »

chrisb wrote: Wed Jun 13, 2018 6:01 pm CheckGeometry tells it's solid and cutting someth e.g. with a boolean cut shows it as well. It must be the meshing which makes it a shell.
Thanks for the two pointers. Why did not I think of it?

When using checkGeometry on a M6x30 screw I get this:
M6x30_checkgeo.png
M6x30_checkgeo.png (121.25 KiB) Viewed 2600 times
screw_cut_trials.fcstd
(283.78 KiB) Downloaded 85 times
The geometry is not valid. I am using:

OS: Ubuntu 16.04.4 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.13920 (Git)
Build type: None
Branch: master
Hash: 08910e71e423c02da46018c47e34002df4fde1f9
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0

The screw I obtained it from the fasteners WB. I just updated it (is there an obvious way of getting the WB version?).

In my special screws, which have a thread pitch of 3mm, I get also an invalid solid, but it says unconnected shell:
CT_Screw_invalid_geo.png
CT_Screw_invalid_geo.png (94.32 KiB) Viewed 2600 times
If I try to cut it with the cube, FreeCAD crashes.

I am not sure what you will load without my WB installed, by the file is this:
screw_cut_trials.fcstd
(369.94 KiB) Downloaded 76 times
When I load these in slic3r, I am getting this:
CT_Screw_slic3r.png
CT_Screw_slic3r.png (37.52 KiB) Viewed 2600 times
I will review the code I am using, as maybe I am doing something really wrong....
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Screw Maker

Post by abdullah »

I know how to cause/prevent the problem. If I use a pitch size of 3mm the problem is there as above. However if I use a pitch size of 2mm there is no problem. Perfect solid to checkGeometry. Perfect solid when cutting. Perfect Import to slic3r.

Any idea why the pitch size could be the problem?
CT_Screw_2mm.png
CT_Screw_2mm.png (27.63 KiB) Viewed 2595 times
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Screw Maker

Post by abdullah »

I have shared my experimental WB in here:
https://github.com/abdullahtahiriyo/ConstructionToy

I do not think it will be generally useful. It is just a toy...

BTW, it requires ScrewMaker 2.2...
Post Reply