MoI discussion forum
MoI discussion forum

Full Version: Is this within the realm of "not too hard" for MoI

From: fcwilt
24 Mar   [#1]
Hi,

I was wondering if, using the script feature, a script could be written to generate basic metric hardware, like a M3 Socket Head machine screw.

I like to complete my designs by including all hardware though I don't need high levels of detail like threads.

I was thinking that if it was possible to specify the length, the diameter (M3, M4, etc.) and the head style (socket head, pan head, button head, flat head) it would then generate the basic shape, maybe even getting fancy and including a basic hex recess in the head.

It would be fantastic if somehow it could create the shape facing in the right direction (up, down, left, right) and at the right position, by clicking on the center of the hole where the fastener needs to end up.

Right now I have a whole collection of different types of fasteners (machine screws, washers, hex nuts, press-in threaded inserts) and I have to import the one I want from the correct file and then set its orientation and then move it into place which involves a minor, but annoying, bit of messing around in the three dimensions.

Just curious if it could be done.

Thanks.

Frederick
From: 777RAVEN777
24 Mar   [#2] In reply to [#1]
Have you tried the 'Nuts And Bolts' script? Download from here https://moiscript.weebly.com/ecrous-et-boulons.html
From: Michael Gibson
24 Mar   [#3] In reply to [#1]
The English one is at https://moi3d.com > Resources > " Max Smirnov's MoI scripts " > then look for "NutsAndBolts.v.0.96.2015.06.22.zip" .

re:
> It would be fantastic if somehow it could create the shape facing in the right direction
> (up, down, left, right) and at the right position, by clicking on the center of the hole
> where the fastener needs to end up.

I don't think it does this part though, but you can use Transform > Orient for this:
https://moi3d.com/4.0/docs/moi_command_reference8.htm#orient

- Michael
From: fcwilt
25 Mar   [#4] In reply to [#3]
Hi Michael,

Well the orient command looks promising.

The nut-and-bolt package is far more complicated then I seek and it produces far more detail than I need - and does not all that detail take more work from MoI?

I look at the two files in the package but I could not make much sense of it - there didn't seem to be enough code in the JS to do all that is does.

I guess I need to try and educate myself on how to do this stuff - let me look at my schedule - oh, good - I've got some free time coming up in 5-6 years. ;)

Frederick
From: Michael Gibson
25 Mar   [#5] In reply to [#4]
Hi Frederick, yes having the threads does take a lot of computation. It is good to remove those if you don't really need them.

You can also find more prebuilt models for bolts and fasteners at McMaster-Carr's web site: https://www.mcmaster.com/

re:
> there didn't seem to be enough code in the JS to do all that is does.

Most of the code for this one is inside of the .htm file.

- Michael
From: fcwilt
25 Mar   [#6] In reply to [#5]
Hi,

McMaster-Carr is one of my goto places for hardware - and they do seem to have CAD files for everything - at lease everything I have purchased had them available - even individual files for things like press-in metric inserts - somebody did a lot of work.

I tried out the align function - pretty neat - it would save time - but I cannot get it to do anything but position the fastener objects at the surface or all the way in the hole - cannot seem to click on the center of the "face" between the "threaded" part and the head of the fastener - maybe if I create the "threaded" part separate from the head.

I will dig into the .htm file - I used to program for a living - but that was 25+ years ago - and much has changed.

Thanks again for all your help.

Frederick
From: Larry Fahnoe (FAHNOE)
25 Mar   [#7] In reply to [#6]
Between Max's Nuts & Bolts script and McMaster, I get pretty much all the hardware models that I need.

Maybe a bit of a subtlety, but note the check box allowing you to include or exclude Head, Shank, Washers, or Nut.

I do acknowledge that the addition of the threads does complicate the models and that Max's code is a challenging to understand.

--Larry
From: fcwilt
25 Mar   [#8] In reply to [#5]
Hi again,

I went back and took a closer look at the .htm file and saw the code you mentioned.

Can this kind of code be executed in a script file or must it be done in an .htm file?

Thanks.

Frederick
From: MO (MO_TE)
25 Mar   [#9] In reply to [#8]
Hi Frederick
If you don't need the threads, you can set the "Thread length" value to 0.
Here you can see this option both in ui and inside .htm file. (Line 97)
Also, "Angle" value controls the head and nut's fillet angle.

Image Attachments:
Nuts&Bolt_1.png  Nuts&Bolt_2.png 


From: Michael Gibson
25 Mar   [#10] In reply to [#8]
Hi Frederick,

re:
> Can this kind of code be executed in a script file or must it be done in an .htm file?

It can go in either the .js file or the .htm file.

A long time ago (maybe V2 ?) there was a performance advantage to putting it in the .htm file which is why it's there. There isn't any difference anymore.

- Michael
From: fcwilt
25 Mar   [#11] In reply to [#9]
Hi,

It's an impressive bit of work but it appears to only make plain head bolts - no socket head, pan head, button head, flat head - all with a hex recess for the Allen tool - and that is what I desire.

Frederick
From: Michael Gibson
25 Mar   [#12] In reply to [#11]
Hi Frederick, you also might check out FreeCAD, it has a fasteners module:
https://wiki.freecad.org/Fasteners_Workbench

- Michael
From: fcwilt
25 Mar   [#13] In reply to [#12]
Hi Michael,

I will check that out - I have heard of FreeCAD but a quick dive into a long while back made me really appreciate MoI.

I've got the "top-of-the-line" Alibre which has a ton of features - and I use Moi for most of my work.

Frederick