Working script to create metric bolts on the fly as block items (but some feedback needed)

https://evanli.github.io/programming-book-3/Python/

1 Like

Violent Python sounds intriguing :open_mouth:

Hi guys, i try this script to create a M7 20mm DIN912… not possible. Only M6 or M8 :disappointed_relieved:

@zzzmutations you can easily add new sizes to the script. This was just a piece of code to learn working with classes in python.
Just add the M7 sizes of bolt diameter, pitch, head size etc to the dictionaries and it will work.
There is also BoltGen that can add bolts with thread to your doc. Or download bolts and nuts from McMaster

Could it be expanded to more Metric sizes above M8? For example, I regularly use M10, M12, M14 in my projects. :slight_smile:

Yes as mentioned this can be done very easily by adding those sizes to the dictionaries in the script. In the beginning of the script you see diameter and pitch sizes and each bolt class has head sizes and/ or hex socket sizes.
You can also send me those measurements then I’ll add those to the script.

Sure, here are the 3d models of most commonly used Metric screws that “BoltGen” creates. I opted for the versions without a thread to reduce the file size. I put a length of 50 mm to each, thought I use different lengths depending on the application.
M6, M8, M10, M12, M14 and M16.3dm (479.9 KB)

no, what I need is info on pitch size and head dimensions. Better if you can provide a table with all dimensions

See if this is helpful:

@Gijs, is it normal that the generated bolts are not threaded yet?

IMO this adds useless complexity to a scene. Instead I’m adding a cosmetic thread only in the form of a curve.

1 Like

I agree and I’ve noticed the helictical curve, but threads would be a nice option in the context of 3D printing. I often times generate a metric bold, scale it up, and use it as a base geometry for a printable screw connection.
For instance, the BoltGen add-on is nice, but has only imperial presets (I believe).

No this is not the case, metric also.

1 Like

@Rhino_Bulgaria here is a slightly better version that adds the metric bolts you mentioned, and organizes them into the correct block item layers.
addBolt_v0.8.py (18.9 KB)

1 Like

This works fantastic! Thank you for the effort to add these screw sizes! :slight_smile: I like that it could orient the screw even on the surface of a round tube, for example, which is very important for me.

1 Like

good to hear :slight_smile: btw, if you need other lengths than the one specified, simply change this in line 117:

    lengths=['12mm','16mm','20mm','25mm','30mm','40mm','50mm','60mm','70mm','80mm']
1 Like

Oh, yes, I was just looking for a way to make M8x35 mm and was unable to do it through the Command line. :slight_smile:

pls download the edited version above @Rhino_Bulgaria

btw2: if you normally use socket allen, then you might also want to change line 108 to:
bolttype= sc.sticky["bolttype"] if sc.sticky.has_key("bolttype") else 2

Yes, this is what I mostly use, however, sometimes I also need hex head screws, so I think that your script has me covered in all situations. :slight_smile:

I think that your script deserves its own icon. :wink:
Add bolt 2

3 Likes